@tap-payments/connect-v2 0.0.23-test → 0.0.25-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.
Files changed (51) hide show
  1. package/build/index.cjs.js +1 -0
  2. package/build/index.d.ts +109 -5
  3. package/build/index.esm.js +345 -0
  4. package/package.json +17 -7
  5. package/build/App.d.ts +0 -2
  6. package/build/App.js +0 -24
  7. package/build/components/loader/Loader.d.ts +0 -9
  8. package/build/components/loader/Loader.js +0 -23
  9. package/build/components/loader/index.d.ts +0 -2
  10. package/build/components/loader/index.js +0 -2
  11. package/build/connect/Connect.d.ts +0 -4
  12. package/build/connect/Connect.js +0 -24
  13. package/build/connect/ConnectIFrame.d.ts +0 -5
  14. package/build/connect/ConnectIFrame.js +0 -16
  15. package/build/connect/index.d.ts +0 -3
  16. package/build/connect/index.js +0 -3
  17. package/build/connect/renderConnectElement.d.ts +0 -5
  18. package/build/connect/renderConnectElement.js +0 -12
  19. package/build/constants.d.ts +0 -5
  20. package/build/constants.js +0 -7
  21. package/build/context/index.d.ts +0 -15
  22. package/build/context/index.js +0 -14
  23. package/build/hooks/index.d.ts +0 -5
  24. package/build/hooks/index.js +0 -5
  25. package/build/hooks/useConfig.d.ts +0 -4
  26. package/build/hooks/useConfig.js +0 -52
  27. package/build/hooks/useEventListener.d.ts +0 -2
  28. package/build/hooks/useEventListener.js +0 -38
  29. package/build/hooks/usePostEvents.d.ts +0 -5
  30. package/build/hooks/usePostEvents.js +0 -11
  31. package/build/hooks/useStopScrolling.d.ts +0 -2
  32. package/build/hooks/useStopScrolling.js +0 -16
  33. package/build/index.js +0 -4
  34. package/build/main.d.ts +0 -1
  35. package/build/main.js +0 -4
  36. package/build/types/app.d.ts +0 -69
  37. package/build/types/app.js +0 -16
  38. package/build/types/events.d.ts +0 -7
  39. package/build/types/events.js +0 -8
  40. package/build/types/index.d.ts +0 -4
  41. package/build/types/index.js +0 -4
  42. package/build/types/searchParams.d.ts +0 -5
  43. package/build/types/searchParams.js +0 -6
  44. package/build/types/theme.d.ts +0 -18
  45. package/build/types/theme.js +0 -22
  46. package/build/utils/dom.d.ts +0 -1
  47. package/build/utils/dom.js +0 -9
  48. package/build/utils/index.d.ts +0 -2
  49. package/build/utils/index.js +0 -2
  50. package/build/utils/region.d.ts +0 -1
  51. package/build/utils/region.js +0 -16
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),f=require("react"),L=require("react-dom");function S(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const l=S(f);var v=(e=>(e.PAGE="page",e.POPUP="popup",e.CONTENT="content",e))(v||{}),b=(e=>(e.AUTH="auth",e.MERCHANT="merchant",e))(b||{}),O=(e=>(e.SET_PASSWORD="set_password",e.RESET_PASSWORD="reset_password",e))(O||{}),y=(e=>(e.DARK="dark",e.LIGHT="light",e))(y||{}),C=(e=>(e.AR="ar",e.EN="en",e))(C||{}),x=(e=>(e.STRAIGHT="straight",e.CURVED="curved",e))(x||{}),j=(e=>(e.LEFT="left",e.RIGHT="right",e.UP="up",e.DOWN="down",e))(j||{}),d=(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))(d||{}),g=(e=>(e.PROFILE_TOKEN="profile_token",e.THEME="theme",e.LANGUAGE="lang",e))(g||{});const T=({outerColor:e="white",innerColor:r="white",duration:t=3,toggleAnimation:n=!1})=>o.jsx("div",{style:{position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%"},children:o.jsx("div",{style:{position:"relative",width:"60px",height:"60px"},children:o.jsxs("svg",{viewBox:"25 25 50 50",style:{transformOrigin:"center center",position:"absolute",top:0,left:0,margin:"auto"},children:[o.jsx("circle",{cx:"50",cy:"50",r:"20",fill:"none",stroke:e,strokeWidth:"3.6px",strokeLinecap:"round",strokeDasharray:"125, 124",children:n&&o.jsxs(o.Fragment,{children:[o.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 50 50",to:"360 50 50",dur:`${t||0/3}s`,repeatCount:"indefinite"}),o.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; 122; 122; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${t}s`,repeatCount:"indefinite"})]})}),o.jsx("circle",{cx:"50",cy:"50",r:"14",fill:"none",stroke:r,strokeWidth:"3.6px",strokeLinecap:"round",strokeDasharray:"88, 124",children:n&&o.jsxs(o.Fragment,{children:[o.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"360 50 50",to:"0 50 50",dur:`${t||0/3}s`,repeatCount:"indefinite"}),o.jsx("animate",{attributeName:"stroke-dashoffset",values:"0; -85; -85; 0; 0",keyTimes:"0; 0.45; 0.55; 0.9; 1",dur:`${t}s`,repeatCount:"indefinite"})]})})]})})}),A=f.memo(T),w=f.createContext({}),E=()=>f.useContext(w);function P({children:e,props:r}){const[t,n]=f.useState(!1),a=s=>{n(s)},i=()=>{n(!1)};return o.jsx(w.Provider,{value:{...r,onLoadingHandler:a,loading:t,onLoaded:i},children:e})}const U="https://68b564fae5dc090291aeddd7.mockapi.io/api/config",I="https://68b564fae5dc090291aeddd7.mockapi.io/api/config",D="https://68b564fae5dc090291aeddd7.mockapi.io/api/config",G="tap-connect-sdk-iframe",h="https://connect.alpha.tap.company",$=({src:e})=>{const{loading:r}=E();return o.jsxs(o.Fragment,{children:[r&&o.jsx(A,{toggleAnimation:!0}),e&&o.jsx("iframe",{id:G,title:"connect",src:e,style:{width:"100%",height:"100%",border:"none",position:"absolute",top:0,left:0}})]})};var F=function(e){var r,t;return((t=(r=e==null?void 0:e.response)===null||r===void 0?void 0:r.data)===null||t===void 0?void 0:t.errors)!==void 0},H=function(e){return e instanceof Error},W=function(e){return typeof e=="string"},K=function(e){try{var r=e.response.data.errors,t=r[0],n=t.description,a=t.code;return{message:n,code:a}}catch(i){return{message:i.message,code:"UNKNOWN"}}},M=function(e){try{var r=e.message,t=r.split("::"),n=t[0],a=t[1];return{message:a,code:n}}catch(i){return{message:i.message,code:"UNKNOWN"}}},q=function(e){try{var r=e.split("::"),t=r[0],n=r[1];return{message:n,code:t}}catch(a){return{message:a,code:"UNKNOWN"}}},B=function(){function e(r){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}),F(r)){var t=K(r);this.code=t.code,this.message=t.message}else if(H(r)){var t=M(r);this.code=t.code,this.message=t.message}else if(W(r)){var t=q(r);this.code=t.code,this.message=t.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 Y=(e="tap-connect-sdk-element")=>{const r=document.getElementById(e);if(r)return r;const t=document.createElement("div");return t.setAttribute("id",e),document.body.prepend(t),t},z=e=>e?["sa","sau"].includes(e.toLowerCase()):!1,J=e=>e==="dr",V=(e="")=>{const[r,t]=e.split("-");return z(r)?J(t)?D:I:U},Q=()=>{const[e,r]=l.useState(""),{onError:t,onLoadingHandler:n,loginMode:a,region:i,...s}=E(),m=async()=>{n(!0);try{const c=await fetch(V(i),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!c.ok)throw new Error(`${c.status}::${c.statusText}`);const u=await c.json();if(!u.redirect_url){const p=new URLSearchParams;s!=null&&s.theme&&p.append(g.THEME,s.theme),s!=null&&s.language&&p.append(g.LANGUAGE,s.language),p.append(g.PROFILE_TOKEN,u.id);const R=a?`${h}/auth`:h;u.redirect_url=`${R}?${p.toString()}`}if(s.mode!==v.PAGE)return r(u.redirect_url);window.location.href=u.redirect_url}catch(c){const u=new B(c);t==null||t(u.getClientError()),n(!1)}};return l.useEffect(()=>{m()},[]),{connectLink:e}},X=()=>{const{onSuccess:e,onClose:r,onError:t,onReady:n,onLoaded:a}=E(),i=l.useCallback(async s=>{if(s.origin!==h)return;const{data:m,event:c}=s.data;switch(c){case d.ON_CLOSE:r==null||r();break;case d.ON_ERROR:t==null||t(m);break;case d.ON_SUCCESS:e(m);break;case d.ON_LOADED:a();break;case d.ON_READY:n==null||n();break}},[r,t,a,n,e]);l.useEffect(()=>(window.addEventListener("message",i,!1),()=>{window.removeEventListener("message",i)}),[i])},Z=()=>{const{connectLink:e}=Q();return X(),o.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:o.jsx($,{src:e})})},ee=e=>o.jsx(P,{props:e,children:e.open&&o.jsx(Z,{})}),_=l.memo(ee);var k,N=L;k=N.createRoot,N.hydrateRoot;const te=(e,r)=>{const t=Y(e),n=k(t);return n.render(o.jsx(_,{...r})),{unmount:()=>n.unmount()}};exports.ConnectDialogEdgeFormat=x;exports.ConnectDialogTransition=j;exports.ConnectElement=_;exports.ConnectLanguage=C;exports.ConnectMode=v;exports.ConnectPasswordOperationType=O;exports.ConnectScope=b;exports.ConnectTheme=y;exports.renderConnectElement=te;
package/build/index.d.ts CHANGED
@@ -1,5 +1,109 @@
1
- import { ConnectProps, ConnectAppInfo, ConnectPaymentProvider, ConnectNotification, ConnectMode, ConnectTheme, ConnectLanguage, ConnectScope, ConnectDialogTransition, ConnectDialogEdgeFormat, ConnectPasswordOperationType } from './types';
2
- import { ConnectElement, renderConnectElement } from './connect';
3
- export type { ConnectProps, ConnectAppInfo, ConnectPaymentProvider, ConnectNotification };
4
- export { ConnectMode, ConnectTheme, ConnectLanguage, ConnectScope, ConnectDialogTransition, ConnectDialogEdgeFormat, ConnectPasswordOperationType, };
5
- export { ConnectElement, renderConnectElement };
1
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
2
+ import * as React_2 from 'react';
3
+
4
+ export declare type ConnectAppInfo = {
5
+ name: string;
6
+ identifier?: string;
7
+ version?: string;
8
+ };
9
+
10
+ export declare enum ConnectDialogEdgeFormat {
11
+ STRAIGHT = "straight",
12
+ CURVED = "curved"
13
+ }
14
+
15
+ export declare enum ConnectDialogTransition {
16
+ LEFT = "left",
17
+ RIGHT = "right",
18
+ UP = "up",
19
+ DOWN = "down"
20
+ }
21
+
22
+ export declare const ConnectElement: React_2.MemoExoticComponent<(props: ConnectProps) => JSX_2.Element>;
23
+
24
+ export declare enum ConnectLanguage {
25
+ AR = "ar",
26
+ EN = "en"
27
+ }
28
+
29
+ export declare enum ConnectMode {
30
+ PAGE = "page",
31
+ POPUP = "popup",
32
+ CONTENT = "content"
33
+ }
34
+
35
+ export declare type ConnectNotification = {
36
+ email: boolean;
37
+ mobile?: boolean;
38
+ };
39
+
40
+ export declare enum ConnectPasswordOperationType {
41
+ SET_PASSWORD = "set_password",
42
+ RESET_PASSWORD = "reset_password"
43
+ }
44
+
45
+ export declare type ConnectPaymentProvider = {
46
+ technology_id: string;
47
+ settlement_by: string;
48
+ };
49
+
50
+ export declare type ConnectProps = {
51
+ onClose?: () => void;
52
+ onSuccess: (res: Record<string, string | number>) => void;
53
+ onError?: (error: CustomError) => void;
54
+ onReady?: () => void;
55
+ open: boolean;
56
+ theme?: ConnectTheme;
57
+ language?: ConnectLanguage;
58
+ publicKey: string;
59
+ merchantDomain: string;
60
+ appInfo: ConnectAppInfo;
61
+ businessCountryCode?: string;
62
+ scope: ConnectScope;
63
+ showBoard?: boolean;
64
+ leadId?: string;
65
+ platforms?: Array<string>;
66
+ paymentProvider?: ConnectPaymentProvider;
67
+ features?: {
68
+ poweredBy?: boolean;
69
+ merchantLogo?: boolean;
70
+ closeButton?: boolean;
71
+ dialogStartTransition?: ConnectDialogTransition;
72
+ dialogEndTransition?: ConnectDialogTransition;
73
+ dialogEdgeFormat?: ConnectDialogEdgeFormat;
74
+ };
75
+ postUrl?: string;
76
+ redirectUrl?: string;
77
+ data?: Array<string>;
78
+ mode?: ConnectMode;
79
+ notification?: ConnectNotification;
80
+ boardEditable?: boolean;
81
+ boardId?: string;
82
+ boardInfoId?: string;
83
+ userId?: string;
84
+ userType?: string;
85
+ operationType?: ConnectPasswordOperationType;
86
+ loginMode?: boolean;
87
+ region?: string;
88
+ };
89
+
90
+ export declare enum ConnectScope {
91
+ AUTH = "auth",
92
+ MERCHANT = "merchant"
93
+ }
94
+
95
+ export declare enum ConnectTheme {
96
+ DARK = "dark",
97
+ LIGHT = "light"
98
+ }
99
+
100
+ declare type CustomError = {
101
+ code: string;
102
+ message: string;
103
+ };
104
+
105
+ export declare const renderConnectElement: (elementId: string, config: ConnectProps) => {
106
+ unmount: () => void;
107
+ };
108
+
109
+ export { }
@@ -0,0 +1,345 @@
1
+ import { jsx as o, jsxs as p, Fragment as v } from "react/jsx-runtime";
2
+ import * as l from "react";
3
+ import g from "react";
4
+ import k from "react-dom";
5
+ var O = /* @__PURE__ */ ((e) => (e.PAGE = "page", e.POPUP = "popup", e.CONTENT = "content", e))(O || {}), w = /* @__PURE__ */ ((e) => (e.AUTH = "auth", e.MERCHANT = "merchant", e))(w || {}), R = /* @__PURE__ */ ((e) => (e.SET_PASSWORD = "set_password", e.RESET_PASSWORD = "reset_password", e))(R || {}), L = /* @__PURE__ */ ((e) => (e.DARK = "dark", e.LIGHT = "light", e))(L || {}), S = /* @__PURE__ */ ((e) => (e.AR = "ar", e.EN = "en", e))(S || {}), A = /* @__PURE__ */ ((e) => (e.STRAIGHT = "straight", e.CURVED = "curved", e))(A || {}), T = /* @__PURE__ */ ((e) => (e.LEFT = "left", e.RIGHT = "right", e.UP = "up", e.DOWN = "down", e))(T || {}), 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.THEME = "theme", e.LANGUAGE = "lang", e))(h || {});
6
+ const x = ({ outerColor: e = "white", innerColor: r = "white", duration: t = 3, toggleAnimation: n = !1 }) => /* @__PURE__ */ o(
7
+ "div",
8
+ {
9
+ style: {
10
+ position: "absolute",
11
+ display: "flex",
12
+ justifyContent: "center",
13
+ alignItems: "center",
14
+ width: "100%",
15
+ height: "100%"
16
+ },
17
+ children: /* @__PURE__ */ o(
18
+ "div",
19
+ {
20
+ style: {
21
+ position: "relative",
22
+ width: "60px",
23
+ height: "60px"
24
+ },
25
+ children: /* @__PURE__ */ p(
26
+ "svg",
27
+ {
28
+ viewBox: "25 25 50 50",
29
+ style: {
30
+ transformOrigin: "center center",
31
+ position: "absolute",
32
+ top: 0,
33
+ left: 0,
34
+ margin: "auto"
35
+ },
36
+ children: [
37
+ /* @__PURE__ */ o(
38
+ "circle",
39
+ {
40
+ cx: "50",
41
+ cy: "50",
42
+ r: "20",
43
+ fill: "none",
44
+ stroke: e,
45
+ strokeWidth: "3.6px",
46
+ strokeLinecap: "round",
47
+ strokeDasharray: "125, 124",
48
+ children: n && /* @__PURE__ */ p(v, { children: [
49
+ /* @__PURE__ */ o(
50
+ "animateTransform",
51
+ {
52
+ attributeName: "transform",
53
+ type: "rotate",
54
+ from: "0 50 50",
55
+ to: "360 50 50",
56
+ dur: `${t || 0 / 3}s`,
57
+ repeatCount: "indefinite"
58
+ }
59
+ ),
60
+ /* @__PURE__ */ o(
61
+ "animate",
62
+ {
63
+ attributeName: "stroke-dashoffset",
64
+ values: "0; 122; 122; 0; 0",
65
+ keyTimes: "0; 0.45; 0.55; 0.9; 1",
66
+ dur: `${t}s`,
67
+ repeatCount: "indefinite"
68
+ }
69
+ )
70
+ ] })
71
+ }
72
+ ),
73
+ /* @__PURE__ */ o(
74
+ "circle",
75
+ {
76
+ cx: "50",
77
+ cy: "50",
78
+ r: "14",
79
+ fill: "none",
80
+ stroke: r,
81
+ strokeWidth: "3.6px",
82
+ strokeLinecap: "round",
83
+ strokeDasharray: "88, 124",
84
+ children: n && /* @__PURE__ */ p(v, { children: [
85
+ /* @__PURE__ */ o(
86
+ "animateTransform",
87
+ {
88
+ attributeName: "transform",
89
+ type: "rotate",
90
+ from: "360 50 50",
91
+ to: "0 50 50",
92
+ dur: `${t || 0 / 3}s`,
93
+ repeatCount: "indefinite"
94
+ }
95
+ ),
96
+ /* @__PURE__ */ o(
97
+ "animate",
98
+ {
99
+ attributeName: "stroke-dashoffset",
100
+ values: "0; -85; -85; 0; 0",
101
+ keyTimes: "0; 0.45; 0.55; 0.9; 1",
102
+ dur: `${t}s`,
103
+ repeatCount: "indefinite"
104
+ }
105
+ )
106
+ ] })
107
+ }
108
+ )
109
+ ]
110
+ }
111
+ )
112
+ }
113
+ )
114
+ }
115
+ ), U = g.memo(x), y = g.createContext({}), N = () => g.useContext(y);
116
+ function I({ children: e, props: r }) {
117
+ const [t, n] = g.useState(!1), a = (s) => {
118
+ n(s);
119
+ }, i = () => {
120
+ n(!1);
121
+ };
122
+ return /* @__PURE__ */ o(y.Provider, { value: { ...r, onLoadingHandler: a, loading: t, onLoaded: i }, children: e });
123
+ }
124
+ const P = "https://68b564fae5dc090291aeddd7.mockapi.io/api/config", G = "https://68b564fae5dc090291aeddd7.mockapi.io/api/config", $ = "https://68b564fae5dc090291aeddd7.mockapi.io/api/config", j = "tap-connect-sdk-iframe", E = "https://connect.alpha.tap.company", D = ({ src: e }) => {
125
+ const { loading: r } = N();
126
+ return /* @__PURE__ */ p(v, { children: [
127
+ r && /* @__PURE__ */ o(U, { toggleAnimation: !0 }),
128
+ e && /* @__PURE__ */ o(
129
+ "iframe",
130
+ {
131
+ id: j,
132
+ title: "connect",
133
+ src: e,
134
+ style: {
135
+ width: "100%",
136
+ height: "100%",
137
+ border: "none",
138
+ position: "absolute",
139
+ top: 0,
140
+ left: 0
141
+ }
142
+ }
143
+ )
144
+ ] });
145
+ };
146
+ var H = function(e) {
147
+ var r, t;
148
+ return ((t = (r = e == null ? void 0 : e.response) === null || r === void 0 ? void 0 : r.data) === null || t === void 0 ? void 0 : t.errors) !== void 0;
149
+ }, W = function(e) {
150
+ return e instanceof Error;
151
+ }, F = function(e) {
152
+ return typeof e == "string";
153
+ }, K = function(e) {
154
+ try {
155
+ var r = e.response.data.errors, t = r[0], n = t.description, a = t.code;
156
+ return {
157
+ message: n,
158
+ code: a
159
+ };
160
+ } catch (i) {
161
+ return {
162
+ message: i.message,
163
+ code: "UNKNOWN"
164
+ };
165
+ }
166
+ }, M = function(e) {
167
+ try {
168
+ var r = e.message, t = r.split("::"), n = t[0], a = t[1];
169
+ return {
170
+ message: a,
171
+ code: n
172
+ };
173
+ } catch (i) {
174
+ return {
175
+ message: i.message,
176
+ code: "UNKNOWN"
177
+ };
178
+ }
179
+ }, B = function(e) {
180
+ try {
181
+ var r = e.split("::"), t = r[0], n = r[1];
182
+ return {
183
+ message: n,
184
+ code: t
185
+ };
186
+ } catch (a) {
187
+ return {
188
+ message: a,
189
+ code: "UNKNOWN"
190
+ };
191
+ }
192
+ }, Y = function() {
193
+ function e(r) {
194
+ if (Object.defineProperty(this, "code", {
195
+ enumerable: !0,
196
+ configurable: !0,
197
+ writable: !0,
198
+ value: void 0
199
+ }), Object.defineProperty(this, "message", {
200
+ enumerable: !0,
201
+ configurable: !0,
202
+ writable: !0,
203
+ value: void 0
204
+ }), H(r)) {
205
+ var t = K(r);
206
+ this.code = t.code, this.message = t.message;
207
+ } else if (W(r)) {
208
+ var t = M(r);
209
+ this.code = t.code, this.message = t.message;
210
+ } else if (F(r)) {
211
+ var t = B(r);
212
+ this.code = t.code, this.message = t.message;
213
+ } else
214
+ this.code = "UNKNOWN", this.message = "Unknown error";
215
+ }
216
+ return Object.defineProperty(e.prototype, "getCode", {
217
+ enumerable: !1,
218
+ configurable: !0,
219
+ writable: !0,
220
+ value: function() {
221
+ return this.code;
222
+ }
223
+ }), Object.defineProperty(e.prototype, "getMessage", {
224
+ enumerable: !1,
225
+ configurable: !0,
226
+ writable: !0,
227
+ value: function() {
228
+ return this.message;
229
+ }
230
+ }), Object.defineProperty(e.prototype, "getClientError", {
231
+ enumerable: !1,
232
+ configurable: !0,
233
+ writable: !0,
234
+ value: function() {
235
+ return {
236
+ message: this.message,
237
+ code: this.code
238
+ };
239
+ }
240
+ }), e;
241
+ }();
242
+ const q = (e = "tap-connect-sdk-element") => {
243
+ const r = document.getElementById(e);
244
+ if (r) return r;
245
+ const t = document.createElement("div");
246
+ return t.setAttribute("id", e), document.body.prepend(t), t;
247
+ }, J = (e) => e ? ["sa", "sau"].includes(e.toLowerCase()) : !1, V = (e) => e === "dr", z = (e = "") => {
248
+ const [r, t] = e.split("-");
249
+ return J(r) ? V(t) ? $ : G : P;
250
+ }, Q = () => {
251
+ const [e, r] = l.useState(""), { onError: t, onLoadingHandler: n, loginMode: a, region: i, ...s } = N(), f = async () => {
252
+ n(!0);
253
+ try {
254
+ const c = await fetch(z(i), {
255
+ method: "POST",
256
+ headers: {
257
+ "Content-Type": "application/json"
258
+ },
259
+ body: JSON.stringify(s)
260
+ });
261
+ if (!c.ok)
262
+ throw new Error(`${c.status}::${c.statusText}`);
263
+ const d = await c.json();
264
+ if (!d.redirect_url) {
265
+ const m = new URLSearchParams();
266
+ s != null && s.theme && m.append(h.THEME, s.theme), s != null && s.language && m.append(h.LANGUAGE, s.language), m.append(h.PROFILE_TOKEN, d.id);
267
+ const _ = a ? `${E}/auth` : E;
268
+ d.redirect_url = `${_}?${m.toString()}`;
269
+ }
270
+ if (s.mode !== O.PAGE) return r(d.redirect_url);
271
+ window.location.href = d.redirect_url;
272
+ } catch (c) {
273
+ const d = new Y(c);
274
+ t == null || t(d.getClientError()), n(!1);
275
+ }
276
+ };
277
+ return l.useEffect(() => {
278
+ f();
279
+ }, []), { connectLink: e };
280
+ }, X = () => {
281
+ const { onSuccess: e, onClose: r, onError: t, onReady: n, onLoaded: a } = N(), i = l.useCallback(
282
+ async (s) => {
283
+ if (s.origin !== E) return;
284
+ const { data: f, event: c } = s.data;
285
+ switch (c) {
286
+ case u.ON_CLOSE:
287
+ r == null || r();
288
+ break;
289
+ case u.ON_ERROR:
290
+ t == null || t(f);
291
+ break;
292
+ case u.ON_SUCCESS:
293
+ e(f);
294
+ break;
295
+ case u.ON_LOADED:
296
+ a();
297
+ break;
298
+ case u.ON_READY:
299
+ n == null || n();
300
+ break;
301
+ }
302
+ },
303
+ [r, t, a, n, e]
304
+ );
305
+ l.useEffect(() => (window.addEventListener("message", i, !1), () => {
306
+ window.removeEventListener("message", i);
307
+ }), [i]);
308
+ }, Z = () => {
309
+ const { connectLink: e } = Q();
310
+ return X(), /* @__PURE__ */ o(
311
+ "div",
312
+ {
313
+ id: "tap-connect-main-container",
314
+ style: {
315
+ display: "flex",
316
+ alignItems: "center",
317
+ justifyContent: "center",
318
+ background: "rgba(0, 0, 0, 0.5)",
319
+ position: "fixed",
320
+ top: 0,
321
+ left: 0,
322
+ width: "100%",
323
+ height: "100%"
324
+ },
325
+ children: /* @__PURE__ */ o(D, { src: e })
326
+ }
327
+ );
328
+ }, ee = (e) => /* @__PURE__ */ o(I, { props: e, children: e.open && /* @__PURE__ */ o(Z, {}) }), te = l.memo(ee);
329
+ var C, b = k;
330
+ C = b.createRoot, b.hydrateRoot;
331
+ const se = (e, r) => {
332
+ const t = q(e), n = C(t);
333
+ return n.render(/* @__PURE__ */ o(te, { ...r })), { unmount: () => n.unmount() };
334
+ };
335
+ export {
336
+ A as ConnectDialogEdgeFormat,
337
+ T as ConnectDialogTransition,
338
+ te as ConnectElement,
339
+ S as ConnectLanguage,
340
+ O as ConnectMode,
341
+ R as ConnectPasswordOperationType,
342
+ w as ConnectScope,
343
+ L as ConnectTheme,
344
+ se as renderConnectElement
345
+ };
package/package.json CHANGED
@@ -1,23 +1,32 @@
1
1
  {
2
2
  "name": "@tap-payments/connect-v2",
3
3
  "private": false,
4
- "version": "0.0.23-test",
4
+ "version": "0.0.25-test",
5
5
  "type": "module",
6
- "main": "build/index.js",
7
- "module": "build/index.js",
6
+ "main": "build/index.cjs.js",
7
+ "module": "build/index.esm.js",
8
8
  "types": "build/index.d.ts",
9
9
  "files": [
10
10
  "build",
11
11
  "readme.md"
12
12
  ],
13
+ "exports": {
14
+ ".": {
15
+ "require": "./build/index.cjs.js",
16
+ "import": "./build/index.esm.js",
17
+ "types": "./build/index.d.ts"
18
+ }
19
+ },
13
20
  "scripts": {
14
21
  "clean": "rm -rf build*",
15
22
  "dev": "vite",
16
23
  "tsc:alias": "tsc-alias -p tsconfig.app.json",
17
- "build": "yarn clean && tsc -b && yarn tsc:alias && vite build",
18
- "build:production": "npm run build -- --mode production",
19
- "build:beta": "npm run build -- --mode beta",
20
- "build:development": "npm run build -- --mode development",
24
+ "build:npm": "cross-env BUILD_TARGET=npm vite build --mode ${MODE:-development}",
25
+ "build:umd": "cross-env BUILD_TARGET=umd vite build --mode ${MODE:-development}",
26
+ "build": "yarn clean && yarn build:npm && yarn build:umd",
27
+ "build:production": "cross-env MODE=production npm run build",
28
+ "build:beta": "cross-env MODE=beta npm run build",
29
+ "build:development": "cross-env MODE=development npm run build",
21
30
  "lint": "eslint .",
22
31
  "lint:fix": "eslint . --fix",
23
32
  "preview": "vite preview",
@@ -39,6 +48,7 @@
39
48
  "@types/react": "^18.3.12",
40
49
  "@types/react-dom": "^18.3.1",
41
50
  "@vitejs/plugin-react": "^4.3.3",
51
+ "cross-env": "^10.0.0",
42
52
  "eslint": "^9.13.0",
43
53
  "eslint-plugin-react-hooks": "^5.0.0",
44
54
  "eslint-plugin-react-refresh": "^0.4.14",
package/build/App.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare function App(): import("react/jsx-runtime").JSX.Element;
2
- export default App;
package/build/App.js DELETED
@@ -1,24 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { ConnectMode, ConnectScope, ConnectDialogTransition, ConnectTheme } from './types';
4
- import { ConnectElement } from './connect';
5
- function App() {
6
- const [open, setOpen] = React.useState(true);
7
- return (_jsx(ConnectElement, { open: open, mode: ConnectMode.POPUP, publicKey: 'pk_test_lat64TEDSvHrUOYAxVRe28PQ', merchantDomain: 'https://connect.dev.tap.company', appInfo: { name: 'SDK V2' }, scope: ConnectScope.MERCHANT, theme: ConnectTheme.LIGHT, features: {
8
- closeButton: true,
9
- poweredBy: true,
10
- merchantLogo: false,
11
- dialogStartTransition: ConnectDialogTransition.UP,
12
- dialogEndTransition: ConnectDialogTransition.DOWN,
13
- }, postUrl: 'https://203zq.wiremockapi.cloud/json', showBoard: true, boardEditable: true, onClose: () => {
14
- console.log('onClose');
15
- setOpen(false);
16
- }, onError: (err) => {
17
- console.log('error', err);
18
- setOpen(false);
19
- }, onSuccess: (res) => {
20
- console.log('success', res);
21
- setOpen(false);
22
- } }));
23
- }
24
- export default App;
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- type LoaderProps = {
3
- outerColor?: string;
4
- innerColor?: string;
5
- duration?: number;
6
- toggleAnimation?: boolean;
7
- };
8
- declare const _default: React.MemoExoticComponent<({ outerColor, innerColor, duration, toggleAnimation }: LoaderProps) => import("react/jsx-runtime").JSX.Element>;
9
- export default _default;
@@ -1,23 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React from 'react';
3
- const Loader = ({ outerColor = 'white', innerColor = 'white', duration = 3, toggleAnimation = false }) => {
4
- return (_jsx("div", { style: {
5
- position: 'absolute',
6
- display: 'flex',
7
- justifyContent: 'center',
8
- alignItems: 'center',
9
- width: '100%',
10
- height: '100%',
11
- }, children: _jsx("div", { style: {
12
- position: 'relative',
13
- width: '60px',
14
- height: '60px',
15
- }, children: _jsxs("svg", { viewBox: "25 25 50 50", style: {
16
- transformOrigin: 'center center',
17
- position: 'absolute',
18
- top: 0,
19
- left: 0,
20
- margin: 'auto',
21
- }, children: [_jsx("circle", { cx: "50", cy: "50", r: "20", fill: "none", stroke: outerColor, strokeWidth: "3.6px", strokeLinecap: "round", strokeDasharray: "125, 124", children: toggleAnimation && (_jsxs(_Fragment, { children: [_jsx("animateTransform", { attributeName: "transform", type: "rotate", from: "0 50 50", to: "360 50 50", dur: `${duration || 0 / 3}s`, repeatCount: "indefinite" }), _jsx("animate", { attributeName: "stroke-dashoffset", values: "0; 122; 122; 0; 0", keyTimes: "0; 0.45; 0.55; 0.9; 1", dur: `${duration}s`, repeatCount: "indefinite" })] })) }), _jsx("circle", { cx: "50", cy: "50", r: "14", fill: "none", stroke: innerColor, strokeWidth: "3.6px", strokeLinecap: "round", strokeDasharray: "88, 124", children: toggleAnimation && (_jsxs(_Fragment, { children: [_jsx("animateTransform", { attributeName: "transform", type: "rotate", from: "360 50 50", to: "0 50 50", dur: `${duration || 0 / 3}s`, repeatCount: "indefinite" }), _jsx("animate", { attributeName: "stroke-dashoffset", values: "0; -85; -85; 0; 0", keyTimes: "0; 0.45; 0.55; 0.9; 1", dur: `${duration}s`, repeatCount: "indefinite" })] })) })] }) }) }));
22
- };
23
- export default React.memo(Loader);
@@ -1,2 +0,0 @@
1
- import Loader from './Loader';
2
- export default Loader;
@@ -1,2 +0,0 @@
1
- import Loader from './Loader';
2
- export default Loader;
@@ -1,4 +0,0 @@
1
- import * as React from 'react';
2
- import { ConnectProps } from '../types';
3
- declare const _default: React.MemoExoticComponent<(props: ConnectProps) => import("react/jsx-runtime").JSX.Element>;
4
- export default _default;
@@ -1,24 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import ConnectIFrame from './ConnectIFrame';
4
- import ConnectContextProvider from '../context';
5
- import { useEventListener, useConfig } from '../hooks';
6
- const Connect = () => {
7
- const { connectLink } = useConfig();
8
- useEventListener();
9
- return (_jsx("div", { id: "tap-connect-main-container", style: {
10
- display: 'flex',
11
- alignItems: 'center',
12
- justifyContent: 'center',
13
- background: 'rgba(0, 0, 0, 0.5)',
14
- position: 'fixed',
15
- top: 0,
16
- left: 0,
17
- width: '100%',
18
- height: '100%',
19
- }, children: _jsx(ConnectIFrame, { src: connectLink }) }));
20
- };
21
- const ConnectElement = (props) => {
22
- return _jsx(ConnectContextProvider, { props: props, children: props.open && _jsx(Connect, {}) });
23
- };
24
- export default React.memo(ConnectElement);
@@ -1,5 +0,0 @@
1
- type props = {
2
- src: string;
3
- };
4
- declare const ConnectIFrame: ({ src }: props) => import("react/jsx-runtime").JSX.Element;
5
- export default ConnectIFrame;
@@ -1,16 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import Loader from '../components/loader';
3
- import { useConnectContext } from '../context';
4
- import { CONNECT_IFRAME_ID } from '../constants';
5
- const ConnectIFrame = ({ src }) => {
6
- const { loading } = useConnectContext();
7
- return (_jsxs(_Fragment, { children: [loading && _jsx(Loader, { toggleAnimation: true }), src && (_jsx("iframe", { id: CONNECT_IFRAME_ID, title: "connect", src: src, style: {
8
- width: '100%',
9
- height: '100%',
10
- border: 'none',
11
- position: 'absolute',
12
- top: 0,
13
- left: 0,
14
- } }))] }));
15
- };
16
- export default ConnectIFrame;
@@ -1,3 +0,0 @@
1
- import ConnectElement from './Connect';
2
- import renderConnectElement from './renderConnectElement';
3
- export { ConnectElement, renderConnectElement };
@@ -1,3 +0,0 @@
1
- import ConnectElement from './Connect';
2
- import renderConnectElement from './renderConnectElement';
3
- export { ConnectElement, renderConnectElement };
@@ -1,5 +0,0 @@
1
- import { ConnectProps } from '../types';
2
- declare const renderConnectElement: (elementId: string, config: ConnectProps) => {
3
- unmount: () => void;
4
- };
5
- export default renderConnectElement;
@@ -1,12 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createRoot } from 'react-dom/client';
3
- import ConnectElement from './Connect';
4
- import { findOrCreateElementAndInject } from '../utils';
5
- const renderConnectElement = (elementId, config) => {
6
- const element = findOrCreateElementAndInject(elementId);
7
- const root = createRoot(element);
8
- root.render(_jsx(ConnectElement, { ...config }));
9
- const unmount = () => root.unmount();
10
- return { unmount };
11
- };
12
- export default renderConnectElement;
@@ -1,5 +0,0 @@
1
- export declare const CONNECT_CONFIG_URL: string;
2
- export declare const CONNECT_CONFIG_URL_SA: string;
3
- export declare const CONNECT_CONFIG_URL_SA_DR: string;
4
- export declare const CONNECT_IFRAME_ID = "tap-connect-sdk-iframe";
5
- export declare const CONNECT_ORIGIN: string;
@@ -1,7 +0,0 @@
1
- // Added mock up api until api ready from Backend
2
- export const CONNECT_CONFIG_URL = import.meta.env.VITE_CONNECT_CONFIG_URL;
3
- export const CONNECT_CONFIG_URL_SA = import.meta.env.VITE_CONNECT_CONFIG_URL_SA;
4
- export const CONNECT_CONFIG_URL_SA_DR = import.meta.env.VITE_CONNECT_CONFIG_URL_SA_DR;
5
- export const CONNECT_IFRAME_ID = 'tap-connect-sdk-iframe';
6
- // TODO: import.meta.env works only in vite build when do npm publish does not work find another way
7
- export const CONNECT_ORIGIN = import.meta.env.VITE_CONNECT_ORIGIN || 'https://connect.alpha.tap.company';
@@ -1,15 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { ConnectProps } from '../types';
3
- type ConnectContextProps = ConnectProps & {
4
- onLoaded: () => void;
5
- loading: boolean;
6
- onLoadingHandler: (val: boolean) => void;
7
- };
8
- export declare const ConnectContext: React.Context<ConnectContextProps>;
9
- export declare const useConnectContext: () => ConnectContextProps;
10
- type ConnectContextProvider = {
11
- children: ReactNode;
12
- props: ConnectProps;
13
- };
14
- export default function ConnectContextProvider({ children, props }: ConnectContextProvider): import("react/jsx-runtime").JSX.Element;
15
- export {};
@@ -1,14 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import React from 'react';
3
- export const ConnectContext = React.createContext({});
4
- export const useConnectContext = () => React.useContext(ConnectContext);
5
- export default function ConnectContextProvider({ children, props }) {
6
- const [loading, setLoading] = React.useState(false);
7
- const onLoadingHandler = (val) => {
8
- setLoading(val);
9
- };
10
- const onLoaded = () => {
11
- setLoading(false);
12
- };
13
- return (_jsx(ConnectContext.Provider, { value: { ...props, onLoadingHandler, loading, onLoaded }, children: children }));
14
- }
@@ -1,5 +0,0 @@
1
- import useConfig from './useConfig';
2
- import useStopScrolling from './useStopScrolling';
3
- import useEventListener from './useEventListener';
4
- import usePostEvents from './usePostEvents';
5
- export { useStopScrolling, useEventListener, useConfig, usePostEvents };
@@ -1,5 +0,0 @@
1
- import useConfig from './useConfig';
2
- import useStopScrolling from './useStopScrolling';
3
- import useEventListener from './useEventListener';
4
- import usePostEvents from './usePostEvents';
5
- export { useStopScrolling, useEventListener, useConfig, usePostEvents };
@@ -1,4 +0,0 @@
1
- declare const useConfig: () => {
2
- connectLink: string;
3
- };
4
- export default useConfig;
@@ -1,52 +0,0 @@
1
- import * as React from 'react';
2
- import { WebErrorHandler } from '@tap-payments/web-error-handing';
3
- import { ConnectMode, SearchParams } from '../types';
4
- import { useConnectContext } from '../context';
5
- import { CONNECT_ORIGIN } from '../constants';
6
- import { getBaseUrl } from '../utils';
7
- const useConfig = () => {
8
- const [connectLink, setConnectLink] = React.useState('');
9
- const { onError, onLoadingHandler, loginMode, region, ...config } = useConnectContext();
10
- const generateConfig = async () => {
11
- onLoadingHandler(true);
12
- try {
13
- // TODO: Do we need further headers/data for the iframe scenario
14
- // TODO: Add proper type for the response
15
- const response = await fetch(getBaseUrl(region), {
16
- method: 'POST',
17
- headers: {
18
- 'Content-Type': 'application/json',
19
- },
20
- body: JSON.stringify(config),
21
- });
22
- if (!response.ok) {
23
- throw new Error(`${response.status}::${response.statusText}`);
24
- }
25
- const data = await response.json();
26
- // TODO: Adding for testing only
27
- if (!data.redirect_url) {
28
- const params = new URLSearchParams();
29
- if (config?.theme)
30
- params.append(SearchParams.THEME, config.theme);
31
- if (config?.language)
32
- params.append(SearchParams.LANGUAGE, config.language);
33
- params.append(SearchParams.PROFILE_TOKEN, data.id);
34
- const baseUrl = loginMode ? `${CONNECT_ORIGIN}/auth` : CONNECT_ORIGIN;
35
- data.redirect_url = `${baseUrl}?${params.toString()}`;
36
- }
37
- if (config.mode !== ConnectMode.PAGE)
38
- return setConnectLink(data.redirect_url);
39
- window.location.href = data.redirect_url;
40
- }
41
- catch (error) {
42
- const customError = new WebErrorHandler(error);
43
- onError?.(customError.getClientError());
44
- onLoadingHandler(false);
45
- }
46
- };
47
- React.useEffect(() => {
48
- generateConfig();
49
- }, []);
50
- return { connectLink };
51
- };
52
- export default useConfig;
@@ -1,2 +0,0 @@
1
- declare const useEventListener: () => void;
2
- export default useEventListener;
@@ -1,38 +0,0 @@
1
- import * as React from 'react';
2
- import { ConnectEvents } from '../types';
3
- import { CONNECT_ORIGIN } from '../constants';
4
- import { useConnectContext } from '../context';
5
- const useEventListener = () => {
6
- const { onSuccess, onClose, onError, onReady, onLoaded } = useConnectContext();
7
- const handleEvent = React.useCallback(async (message) => {
8
- if (message.origin !== CONNECT_ORIGIN)
9
- return;
10
- const { data, event } = message.data;
11
- switch (event) {
12
- case ConnectEvents.ON_CLOSE:
13
- onClose?.();
14
- break;
15
- case ConnectEvents.ON_ERROR:
16
- onError?.(data);
17
- break;
18
- case ConnectEvents.ON_SUCCESS:
19
- onSuccess(data);
20
- break;
21
- case ConnectEvents.ON_LOADED:
22
- onLoaded();
23
- break;
24
- case ConnectEvents.ON_READY:
25
- onReady?.();
26
- break;
27
- default:
28
- break;
29
- }
30
- }, [onClose, onError, onLoaded, onReady, onSuccess]);
31
- React.useEffect(() => {
32
- window.addEventListener('message', handleEvent, false);
33
- return () => {
34
- window.removeEventListener('message', handleEvent);
35
- };
36
- }, [handleEvent]);
37
- };
38
- export default useEventListener;
@@ -1,5 +0,0 @@
1
- import { ConnectEvents } from '../types';
2
- declare const usePostEvents: () => {
3
- send: <T>(event: ConnectEvents, data: T) => void;
4
- };
5
- export default usePostEvents;
@@ -1,11 +0,0 @@
1
- import { CONNECT_IFRAME_ID } from '../constants';
2
- const usePostEvents = () => {
3
- const send = (event, data) => {
4
- const iframeEl = document.getElementById(CONNECT_IFRAME_ID);
5
- if (!iframeEl)
6
- return;
7
- iframeEl.contentWindow?.postMessage({ event, data });
8
- };
9
- return { send };
10
- };
11
- export default usePostEvents;
@@ -1,2 +0,0 @@
1
- declare const useStopScrolling: () => void;
2
- export default useStopScrolling;
@@ -1,16 +0,0 @@
1
- import * as React from 'react';
2
- const useStopScrolling = () => {
3
- const stopScrolling = () => {
4
- document.body.style.overflow = 'hidden';
5
- };
6
- const startScrolling = () => {
7
- document.body.style.overflow = 'auto';
8
- };
9
- React.useEffect(() => {
10
- stopScrolling();
11
- return () => {
12
- startScrolling();
13
- };
14
- }, []);
15
- };
16
- export default useStopScrolling;
package/build/index.js DELETED
@@ -1,4 +0,0 @@
1
- import { ConnectMode, ConnectTheme, ConnectLanguage, ConnectScope, ConnectDialogTransition, ConnectDialogEdgeFormat, ConnectPasswordOperationType, } from './types';
2
- import { ConnectElement, renderConnectElement } from './connect';
3
- export { ConnectMode, ConnectTheme, ConnectLanguage, ConnectScope, ConnectDialogTransition, ConnectDialogEdgeFormat, ConnectPasswordOperationType, };
4
- export { ConnectElement, renderConnectElement };
package/build/main.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/build/main.js DELETED
@@ -1,4 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createRoot } from 'react-dom/client';
3
- import App from './App';
4
- createRoot(document.getElementById('root')).render(_jsx(App, {}));
@@ -1,69 +0,0 @@
1
- import { ConnectDialogEdgeFormat, ConnectDialogTransition, ConnectLanguage, ConnectTheme } from './theme';
2
- export type CustomError = {
3
- code: string;
4
- message: string;
5
- };
6
- export type ConnectAppInfo = {
7
- name: string;
8
- identifier?: string;
9
- version?: string;
10
- };
11
- export type ConnectPaymentProvider = {
12
- technology_id: string;
13
- settlement_by: string;
14
- };
15
- export type ConnectNotification = {
16
- email: boolean;
17
- mobile?: boolean;
18
- };
19
- export declare enum ConnectMode {
20
- PAGE = "page",
21
- POPUP = "popup",
22
- CONTENT = "content"
23
- }
24
- export declare enum ConnectScope {
25
- AUTH = "auth",
26
- MERCHANT = "merchant"
27
- }
28
- export declare enum ConnectPasswordOperationType {
29
- SET_PASSWORD = "set_password",
30
- RESET_PASSWORD = "reset_password"
31
- }
32
- export type ConnectProps = {
33
- onClose?: () => void;
34
- onSuccess: (res: Record<string, string | number>) => void;
35
- onError?: (error: CustomError) => void;
36
- onReady?: () => void;
37
- open: boolean;
38
- theme?: ConnectTheme;
39
- language?: ConnectLanguage;
40
- publicKey: string;
41
- merchantDomain: string;
42
- appInfo: ConnectAppInfo;
43
- businessCountryCode?: string;
44
- scope: ConnectScope;
45
- showBoard?: boolean;
46
- platforms?: Array<string>;
47
- paymentProvider?: ConnectPaymentProvider;
48
- features?: {
49
- poweredBy?: boolean;
50
- merchantLogo?: boolean;
51
- closeButton?: boolean;
52
- dialogStartTransition?: ConnectDialogTransition;
53
- dialogEndTransition?: ConnectDialogTransition;
54
- dialogEdgeFormat?: ConnectDialogEdgeFormat;
55
- };
56
- postUrl?: string;
57
- redirectUrl?: string;
58
- data?: Array<string>;
59
- mode?: ConnectMode;
60
- notification?: ConnectNotification;
61
- boardEditable?: boolean;
62
- boardId?: string;
63
- boardInfoId?: string;
64
- userId?: string;
65
- userType?: string;
66
- operationType?: ConnectPasswordOperationType;
67
- loginMode?: boolean;
68
- region?: string;
69
- };
@@ -1,16 +0,0 @@
1
- export var ConnectMode;
2
- (function (ConnectMode) {
3
- ConnectMode["PAGE"] = "page";
4
- ConnectMode["POPUP"] = "popup";
5
- ConnectMode["CONTENT"] = "content";
6
- })(ConnectMode || (ConnectMode = {}));
7
- export var ConnectScope;
8
- (function (ConnectScope) {
9
- ConnectScope["AUTH"] = "auth";
10
- ConnectScope["MERCHANT"] = "merchant";
11
- })(ConnectScope || (ConnectScope = {}));
12
- export var ConnectPasswordOperationType;
13
- (function (ConnectPasswordOperationType) {
14
- ConnectPasswordOperationType["SET_PASSWORD"] = "set_password";
15
- ConnectPasswordOperationType["RESET_PASSWORD"] = "reset_password";
16
- })(ConnectPasswordOperationType || (ConnectPasswordOperationType = {}));
@@ -1,7 +0,0 @@
1
- export declare enum ConnectEvents {
2
- ON_CLOSE = "connect:onClose",
3
- ON_ERROR = "connect:onError",
4
- ON_SUCCESS = "connect:onSuccess",
5
- ON_READY = "connect:onReady",
6
- ON_LOADED = "connect:onLoaded"
7
- }
@@ -1,8 +0,0 @@
1
- export var ConnectEvents;
2
- (function (ConnectEvents) {
3
- ConnectEvents["ON_CLOSE"] = "connect:onClose";
4
- ConnectEvents["ON_ERROR"] = "connect:onError";
5
- ConnectEvents["ON_SUCCESS"] = "connect:onSuccess";
6
- ConnectEvents["ON_READY"] = "connect:onReady";
7
- ConnectEvents["ON_LOADED"] = "connect:onLoaded";
8
- })(ConnectEvents || (ConnectEvents = {}));
@@ -1,4 +0,0 @@
1
- export * from './app';
2
- export * from './theme';
3
- export * from './events';
4
- export * from './searchParams';
@@ -1,4 +0,0 @@
1
- export * from './app';
2
- export * from './theme';
3
- export * from './events';
4
- export * from './searchParams';
@@ -1,5 +0,0 @@
1
- export declare enum SearchParams {
2
- PROFILE_TOKEN = "profile_token",
3
- THEME = "theme",
4
- LANGUAGE = "lang"
5
- }
@@ -1,6 +0,0 @@
1
- export var SearchParams;
2
- (function (SearchParams) {
3
- SearchParams["PROFILE_TOKEN"] = "profile_token";
4
- SearchParams["THEME"] = "theme";
5
- SearchParams["LANGUAGE"] = "lang";
6
- })(SearchParams || (SearchParams = {}));
@@ -1,18 +0,0 @@
1
- export declare enum ConnectTheme {
2
- DARK = "dark",
3
- LIGHT = "light"
4
- }
5
- export declare enum ConnectLanguage {
6
- AR = "ar",
7
- EN = "en"
8
- }
9
- export declare enum ConnectDialogEdgeFormat {
10
- STRAIGHT = "straight",
11
- CURVED = "curved"
12
- }
13
- export declare enum ConnectDialogTransition {
14
- LEFT = "left",
15
- RIGHT = "right",
16
- UP = "up",
17
- DOWN = "down"
18
- }
@@ -1,22 +0,0 @@
1
- export var ConnectTheme;
2
- (function (ConnectTheme) {
3
- ConnectTheme["DARK"] = "dark";
4
- ConnectTheme["LIGHT"] = "light";
5
- })(ConnectTheme || (ConnectTheme = {}));
6
- export var ConnectLanguage;
7
- (function (ConnectLanguage) {
8
- ConnectLanguage["AR"] = "ar";
9
- ConnectLanguage["EN"] = "en";
10
- })(ConnectLanguage || (ConnectLanguage = {}));
11
- export var ConnectDialogEdgeFormat;
12
- (function (ConnectDialogEdgeFormat) {
13
- ConnectDialogEdgeFormat["STRAIGHT"] = "straight";
14
- ConnectDialogEdgeFormat["CURVED"] = "curved";
15
- })(ConnectDialogEdgeFormat || (ConnectDialogEdgeFormat = {}));
16
- export var ConnectDialogTransition;
17
- (function (ConnectDialogTransition) {
18
- ConnectDialogTransition["LEFT"] = "left";
19
- ConnectDialogTransition["RIGHT"] = "right";
20
- ConnectDialogTransition["UP"] = "up";
21
- ConnectDialogTransition["DOWN"] = "down";
22
- })(ConnectDialogTransition || (ConnectDialogTransition = {}));
@@ -1 +0,0 @@
1
- export declare const findOrCreateElementAndInject: (id?: string) => HTMLElement;
@@ -1,9 +0,0 @@
1
- export const findOrCreateElementAndInject = (id = 'tap-connect-sdk-element') => {
2
- const elementExist = document.getElementById(id);
3
- if (elementExist)
4
- return elementExist;
5
- const element = document.createElement('div');
6
- element.setAttribute('id', id);
7
- document.body.prepend(element);
8
- return element;
9
- };
@@ -1,2 +0,0 @@
1
- export * from './dom';
2
- export * from './region';
@@ -1,2 +0,0 @@
1
- export * from './dom';
2
- export * from './region';
@@ -1 +0,0 @@
1
- export declare const getBaseUrl: (region?: string | undefined) => string;
@@ -1,16 +0,0 @@
1
- import { CONNECT_CONFIG_URL, CONNECT_CONFIG_URL_SA, CONNECT_CONFIG_URL_SA_DR } from '../constants';
2
- const isSA = (country) => {
3
- if (!country)
4
- return false;
5
- return ['sa', 'sau'].includes(country.toLowerCase());
6
- };
7
- const isDisasterRecoveryEnv = (type) => type === 'dr';
8
- export const getBaseUrl = (region = '') => {
9
- const [country, envType] = region.split('-');
10
- if (isSA(country)) {
11
- return isDisasterRecoveryEnv(envType) ? CONNECT_CONFIG_URL_SA_DR : CONNECT_CONFIG_URL_SA;
12
- }
13
- else {
14
- return CONNECT_CONFIG_URL;
15
- }
16
- };