@flash-pay/react 0.1.0

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.
@@ -0,0 +1,14 @@
1
+ import { PaymentEventData, PaymentData } from '@flash-pay/browser-sdk';
2
+ export type { PaymentEventData, PaymentData };
3
+ export interface FlashpayCheckoutProps {
4
+ transactionId: string;
5
+ onSuccess?: (data: PaymentEventData) => void;
6
+ onFailure?: (data: PaymentEventData) => void;
7
+ onClose?: (data: PaymentEventData) => void;
8
+ showTitle?: boolean;
9
+ showDescription?: boolean;
10
+ showAmount?: boolean;
11
+ style?: Partial<CSSStyleDeclaration>;
12
+ origin?: string;
13
+ }
14
+ export declare function FlashpayCheckout({ transactionId, onSuccess, onFailure, onClose, showTitle, showDescription, showAmount, style, origin, }: FlashpayCheckoutProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react/jsx-runtime"),b=require("@flash-pay/browser-sdk"),e=require("react");function j({transactionId:u,onSuccess:c,onFailure:n,onClose:s,showTitle:o,showDescription:f,showAmount:a,style:d,origin:R}){const t=e.useRef(null),i=e.useRef(c),l=e.useRef(n),y=e.useRef(s);return e.useEffect(()=>{i.current=c,l.current=n,y.current=s}),e.useEffect(()=>{if(!t.current)return;const k=b.checkout({transactionId:u,container:t.current,onSuccess:r=>i.current?.(r),onFailure:r=>l.current?.(r),onClose:r=>y.current?.(r),showTitle:o,showDescription:f,showAmount:a,style:d,origin:R});return()=>k.destroy()},[u,o,f,a,R]),S.jsx("div",{ref:t})}exports.FlashpayCheckout=j;
2
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/FlashpayCheckout.tsx"],"sourcesContent":["import { checkout } from \"@flash-pay/browser-sdk\";\nimport type { PaymentEventData, PaymentData } from \"@flash-pay/browser-sdk\";\nimport { useEffect, useRef } from \"react\";\n\nexport type { PaymentEventData, PaymentData };\n\nexport interface FlashpayCheckoutProps {\n transactionId: string;\n onSuccess?: (data: PaymentEventData) => void;\n onFailure?: (data: PaymentEventData) => void;\n onClose?: (data: PaymentEventData) => void;\n showTitle?: boolean;\n showDescription?: boolean;\n showAmount?: boolean;\n style?: Partial<CSSStyleDeclaration>;\n origin?: string;\n}\n\nexport function FlashpayCheckout({\n transactionId,\n onSuccess,\n onFailure,\n onClose,\n showTitle,\n showDescription,\n showAmount,\n style,\n origin,\n}: FlashpayCheckoutProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Stable refs so callback identity changes don't re-initialize the SDK\n const onSuccessRef = useRef(onSuccess);\n const onFailureRef = useRef(onFailure);\n const onCloseRef = useRef(onClose);\n useEffect(() => {\n onSuccessRef.current = onSuccess;\n onFailureRef.current = onFailure;\n onCloseRef.current = onClose;\n });\n\n useEffect(() => {\n if (!containerRef.current) return;\n const instance = checkout({\n transactionId,\n container: containerRef.current,\n onSuccess: (data) => onSuccessRef.current?.(data),\n onFailure: (data) => onFailureRef.current?.(data),\n onClose: (data) => onCloseRef.current?.(data),\n showTitle,\n showDescription,\n showAmount,\n style,\n origin,\n });\n return () => instance.destroy();\n }, [transactionId, showTitle, showDescription, showAmount, origin]);\n\n return <div ref={containerRef} />;\n}\n"],"names":["FlashpayCheckout","transactionId","onSuccess","onFailure","onClose","showTitle","showDescription","showAmount","style","origin","containerRef","useRef","onSuccessRef","onFailureRef","onCloseRef","useEffect","instance","checkout","data","jsx"],"mappings":"4KAkBO,SAASA,EAAiB,CAC/B,cAAAC,EACA,UAAAC,EACA,UAAAC,EACA,QAAAC,EACA,UAAAC,EACA,gBAAAC,EACA,WAAAC,EACA,MAAAC,EACA,OAAAC,CACF,EAA0B,CACxB,MAAMC,EAAeC,EAAAA,OAAuB,IAAI,EAG1CC,EAAeD,EAAAA,OAAOT,CAAS,EAC/BW,EAAeF,EAAAA,OAAOR,CAAS,EAC/BW,EAAaH,EAAAA,OAAOP,CAAO,EACjCW,OAAAA,EAAAA,UAAU,IAAM,CACdH,EAAa,QAAUV,EACvBW,EAAa,QAAUV,EACvBW,EAAW,QAAUV,CACvB,CAAC,EAEDW,EAAAA,UAAU,IAAM,CACd,GAAI,CAACL,EAAa,QAAS,OAC3B,MAAMM,EAAWC,EAAAA,SAAS,CACxB,cAAAhB,EACA,UAAWS,EAAa,QACxB,UAAYQ,GAASN,EAAa,UAAUM,CAAI,EAChD,UAAYA,GAASL,EAAa,UAAUK,CAAI,EAChD,QAAUA,GAASJ,EAAW,UAAUI,CAAI,EAC5C,UAAAb,EACA,gBAAAC,EACA,WAAAC,EACA,MAAAC,EACA,OAAAC,CAAA,CACD,EACD,MAAO,IAAMO,EAAS,QAAA,CACxB,EAAG,CAACf,EAAeI,EAAWC,EAAiBC,EAAYE,CAAM,CAAC,EAE3DU,EAAAA,IAAC,MAAA,CAAI,IAAKT,CAAA,CAAc,CACjC"}
@@ -0,0 +1,2 @@
1
+ export { FlashpayCheckout } from './FlashpayCheckout';
2
+ export type { FlashpayCheckoutProps, PaymentEventData, PaymentData } from './FlashpayCheckout';
@@ -0,0 +1,38 @@
1
+ import { jsx as y } from "react/jsx-runtime";
2
+ import { checkout as C } from "@flash-pay/browser-sdk";
3
+ import { useRef as e, useEffect as p } from "react";
4
+ function v({
5
+ transactionId: t,
6
+ onSuccess: c,
7
+ onFailure: u,
8
+ onClose: o,
9
+ showTitle: f,
10
+ showDescription: s,
11
+ showAmount: m,
12
+ style: k,
13
+ origin: R
14
+ }) {
15
+ const n = e(null), a = e(c), i = e(u), l = e(o);
16
+ return p(() => {
17
+ a.current = c, i.current = u, l.current = o;
18
+ }), p(() => {
19
+ if (!n.current) return;
20
+ const x = C({
21
+ transactionId: t,
22
+ container: n.current,
23
+ onSuccess: (r) => a.current?.(r),
24
+ onFailure: (r) => i.current?.(r),
25
+ onClose: (r) => l.current?.(r),
26
+ showTitle: f,
27
+ showDescription: s,
28
+ showAmount: m,
29
+ style: k,
30
+ origin: R
31
+ });
32
+ return () => x.destroy();
33
+ }, [t, f, s, m, R]), /* @__PURE__ */ y("div", { ref: n });
34
+ }
35
+ export {
36
+ v as FlashpayCheckout
37
+ };
38
+ //# sourceMappingURL=index.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.es.js","sources":["../src/FlashpayCheckout.tsx"],"sourcesContent":["import { checkout } from \"@flash-pay/browser-sdk\";\nimport type { PaymentEventData, PaymentData } from \"@flash-pay/browser-sdk\";\nimport { useEffect, useRef } from \"react\";\n\nexport type { PaymentEventData, PaymentData };\n\nexport interface FlashpayCheckoutProps {\n transactionId: string;\n onSuccess?: (data: PaymentEventData) => void;\n onFailure?: (data: PaymentEventData) => void;\n onClose?: (data: PaymentEventData) => void;\n showTitle?: boolean;\n showDescription?: boolean;\n showAmount?: boolean;\n style?: Partial<CSSStyleDeclaration>;\n origin?: string;\n}\n\nexport function FlashpayCheckout({\n transactionId,\n onSuccess,\n onFailure,\n onClose,\n showTitle,\n showDescription,\n showAmount,\n style,\n origin,\n}: FlashpayCheckoutProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Stable refs so callback identity changes don't re-initialize the SDK\n const onSuccessRef = useRef(onSuccess);\n const onFailureRef = useRef(onFailure);\n const onCloseRef = useRef(onClose);\n useEffect(() => {\n onSuccessRef.current = onSuccess;\n onFailureRef.current = onFailure;\n onCloseRef.current = onClose;\n });\n\n useEffect(() => {\n if (!containerRef.current) return;\n const instance = checkout({\n transactionId,\n container: containerRef.current,\n onSuccess: (data) => onSuccessRef.current?.(data),\n onFailure: (data) => onFailureRef.current?.(data),\n onClose: (data) => onCloseRef.current?.(data),\n showTitle,\n showDescription,\n showAmount,\n style,\n origin,\n });\n return () => instance.destroy();\n }, [transactionId, showTitle, showDescription, showAmount, origin]);\n\n return <div ref={containerRef} />;\n}\n"],"names":["FlashpayCheckout","transactionId","onSuccess","onFailure","onClose","showTitle","showDescription","showAmount","style","origin","containerRef","useRef","onSuccessRef","onFailureRef","onCloseRef","useEffect","instance","checkout","data","jsx"],"mappings":";;;AAkBO,SAASA,EAAiB;AAAA,EAC/B,eAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AACF,GAA0B;AACxB,QAAMC,IAAeC,EAAuB,IAAI,GAG1CC,IAAeD,EAAOT,CAAS,GAC/BW,IAAeF,EAAOR,CAAS,GAC/BW,IAAaH,EAAOP,CAAO;AACjC,SAAAW,EAAU,MAAM;AACd,IAAAH,EAAa,UAAUV,GACvBW,EAAa,UAAUV,GACvBW,EAAW,UAAUV;AAAA,EACvB,CAAC,GAEDW,EAAU,MAAM;AACd,QAAI,CAACL,EAAa,QAAS;AAC3B,UAAMM,IAAWC,EAAS;AAAA,MACxB,eAAAhB;AAAA,MACA,WAAWS,EAAa;AAAA,MACxB,WAAW,CAACQ,MAASN,EAAa,UAAUM,CAAI;AAAA,MAChD,WAAW,CAACA,MAASL,EAAa,UAAUK,CAAI;AAAA,MAChD,SAAS,CAACA,MAASJ,EAAW,UAAUI,CAAI;AAAA,MAC5C,WAAAb;AAAA,MACA,iBAAAC;AAAA,MACA,YAAAC;AAAA,MACA,OAAAC;AAAA,MACA,QAAAC;AAAA,IAAA,CACD;AACD,WAAO,MAAMO,EAAS,QAAA;AAAA,EACxB,GAAG,CAACf,GAAeI,GAAWC,GAAiBC,GAAYE,CAAM,CAAC,GAE3D,gBAAAU,EAAC,OAAA,EAAI,KAAKT,EAAA,CAAc;AACjC;"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@flash-pay/react",
3
+ "version": "0.1.0",
4
+ "description": "Flashpay React component wrapper",
5
+ "main": "./dist/index.cjs.js",
6
+ "module": "./dist/index.es.js",
7
+ "types": "./dist/index.d.ts",
8
+ "sideEffects": false,
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.es.js",
12
+ "require": "./dist/index.cjs.js",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "files": ["dist"],
17
+ "scripts": {
18
+ "build": "vite build",
19
+ "dev": "vite build --watch",
20
+ "test": "vitest run",
21
+ "test:watch": "vitest"
22
+ },
23
+ "peerDependencies": {
24
+ "@flash-pay/browser-sdk": ">=0.1.0",
25
+ "react": ">=18.0.0",
26
+ "react-dom": ">=18.0.0"
27
+ },
28
+ "devDependencies": {
29
+ "@flash-pay/browser-sdk": "workspace:*",
30
+ "@testing-library/react": "^16.0.0",
31
+ "@types/react": "^18.0.0",
32
+ "@types/react-dom": "^18.0.0",
33
+ "@vitejs/plugin-react": "^4.0.0",
34
+ "ajv": "^8.18.0",
35
+ "jsdom": "^26.0.0",
36
+ "react": "^18.0.0",
37
+ "react-dom": "^18.0.0",
38
+ "typescript": "^5.3.3",
39
+ "vite": "^7.3.1",
40
+ "vite-plugin-dts": "^4.5.4",
41
+ "vitest": "^3.0.0"
42
+ }
43
+ }