@getopenpay/openpay-js-react 0.0.1 → 0.0.2-alpha.6c3bbd9
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/dist/index.d.ts +51 -12
- package/dist/index.js +853 -730
- package/package.json +13 -3
- package/.env.development +0 -1
- package/.env.production +0 -1
- package/.env.staging +0 -1
- package/.eslintrc.cjs +0 -18
- package/.github/workflows/alpha-release.yml +0 -39
- package/.github/workflows/release.yml +0 -30
- package/Makefile +0 -37
- package/example/.eslintrc.json +0 -3
- package/example/Makefile +0 -10
- package/example/README.md +0 -36
- package/example/next.config.mjs +0 -4
- package/example/package-lock.json +0 -5283
- package/example/package.json +0 -27
- package/example/postcss.config.mjs +0 -8
- package/example/public/next.svg +0 -1
- package/example/public/vercel.svg +0 -1
- package/example/src/app/elements/_components/FormWrapper.tsx +0 -18
- package/example/src/app/elements/_components/InputField.tsx +0 -11
- package/example/src/app/elements/card/page.tsx +0 -54
- package/example/src/app/elements/card-cvc/page.tsx +0 -29
- package/example/src/app/elements/card-expiry/page.tsx +0 -29
- package/example/src/app/elements/card-number/page.tsx +0 -29
- package/example/src/app/favicon.ico +0 -0
- package/example/src/app/globals.css +0 -14
- package/example/src/app/layout.tsx +0 -22
- package/example/src/app/page.tsx +0 -119
- package/example/tailwind.config.ts +0 -11
- package/example/tsconfig.json +0 -26
- package/lib/components/_common/frame.tsx +0 -73
- package/lib/components/card-cvc.tsx +0 -11
- package/lib/components/card-expiry.tsx +0 -11
- package/lib/components/card-number.tsx +0 -11
- package/lib/components/card.tsx +0 -11
- package/lib/components/form.tsx +0 -100
- package/lib/hooks/context.ts +0 -17
- package/lib/hooks/use-openpay-elements.ts +0 -12
- package/lib/index.ts +0 -16
- package/lib/utils/constants.ts +0 -1
- package/lib/utils/element.ts +0 -5
- package/lib/utils/event.ts +0 -66
- package/lib/utils/style.ts +0 -17
- package/lib/vite-env.d.ts +0 -1
- package/ngrok.example.yml +0 -6
- package/playwright.config.ts +0 -37
- package/tests/card-cvc.test.ts +0 -68
- package/tests/card-element.test.ts +0 -113
- package/tests/card-expiry.test.ts +0 -61
- package/tests/card-number.test.ts +0 -61
- package/tests/constants.ts +0 -97
- package/tsconfig.build.json +0 -28
- package/tsconfig.json +0 -11
- package/tsconfig.node.json +0 -13
- package/vite.config.ts +0 -36
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { PropsWithChildren } from 'react';
|
|
3
2
|
import { z } from 'zod';
|
|
4
3
|
|
|
4
|
+
declare const AllFieldNames: z.ZodUnion<[z.ZodNativeEnum<typeof FieldName>, z.ZodNativeEnum<typeof PrivateFieldName>]>;
|
|
5
|
+
|
|
6
|
+
declare type AllFieldNames = z.infer<typeof AllFieldNames>;
|
|
7
|
+
|
|
5
8
|
export declare const CardCvcElement: FC<ElementProps>;
|
|
6
9
|
|
|
7
10
|
export declare const CardElement: FC<ElementProps>;
|
|
@@ -10,30 +13,43 @@ export declare const CardExpiryElement: FC<ElementProps>;
|
|
|
10
13
|
|
|
11
14
|
export declare const CardNumberElement: FC<ElementProps>;
|
|
12
15
|
|
|
13
|
-
declare type ElementProps = {
|
|
14
|
-
styles?:
|
|
16
|
+
export declare type ElementProps = {
|
|
17
|
+
styles?: ElementsStyle;
|
|
15
18
|
};
|
|
16
19
|
|
|
17
20
|
declare type ElementsContextValue = {
|
|
18
|
-
|
|
19
|
-
createToken: () => void;
|
|
20
|
-
dispatchEvent: (event: MessageEvent, frame: HTMLIFrameElement) => void;
|
|
21
|
+
formId: string;
|
|
21
22
|
formHeight: string;
|
|
23
|
+
referer?: string;
|
|
24
|
+
checkoutSecureToken?: string;
|
|
25
|
+
registerIframe: (iframe: HTMLIFrameElement) => void;
|
|
22
26
|
};
|
|
23
27
|
|
|
24
28
|
export declare const ElementsForm: FC<ElementsFormProps>;
|
|
25
29
|
|
|
26
|
-
declare
|
|
30
|
+
declare type ElementsFormChildrenProps = {
|
|
31
|
+
submit: () => void;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export declare type ElementsFormProps = {
|
|
27
35
|
className?: string;
|
|
36
|
+
checkoutSecureToken?: string;
|
|
37
|
+
children: (props: ElementsFormChildrenProps) => JSX.Element;
|
|
28
38
|
onFocus?: (elementId: string) => void;
|
|
29
39
|
onBlur?: (elementId: string) => void;
|
|
30
40
|
onChange?: (elementId: string) => void;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
onLoad?: (totalAmountAtoms: number, currency?: string) => void;
|
|
42
|
+
onLoadError?: (message: string) => void;
|
|
43
|
+
onValidationError?: (field: AllFieldNames, errors: string[], elementId?: string) => void;
|
|
44
|
+
onCheckoutStarted?: () => void;
|
|
45
|
+
onCheckoutSuccess?: (invoiceUrls: string[]) => void;
|
|
46
|
+
onCheckoutError?: (message: string) => void;
|
|
47
|
+
};
|
|
35
48
|
|
|
36
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Styles
|
|
51
|
+
*/
|
|
52
|
+
declare const ElementsStyle: z.ZodObject<{
|
|
37
53
|
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
38
54
|
color: z.ZodOptional<z.ZodString>;
|
|
39
55
|
fontFamily: z.ZodOptional<z.ZodString>;
|
|
@@ -59,6 +75,29 @@ declare const ElementStyleSchema: z.ZodObject<{
|
|
|
59
75
|
padding?: string | undefined;
|
|
60
76
|
}>;
|
|
61
77
|
|
|
78
|
+
declare type ElementsStyle = z.infer<typeof ElementsStyle>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Expected input fields
|
|
82
|
+
*/
|
|
83
|
+
export declare enum FieldName {
|
|
84
|
+
FIRST_NAME = "firstName",
|
|
85
|
+
LAST_NAME = "lastName",
|
|
86
|
+
EMAIL = "email",
|
|
87
|
+
ZIP_CODE = "zipCode",
|
|
88
|
+
CITY = "city",
|
|
89
|
+
STATE = "state",
|
|
90
|
+
COUNTRY = "country",
|
|
91
|
+
ADDRESS = "address",
|
|
92
|
+
PHONE = "phone"
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
declare enum PrivateFieldName {
|
|
96
|
+
CARD_NUMBER = "cardNumber",
|
|
97
|
+
CARD_EXPIRY = "cardExpiry",
|
|
98
|
+
CARD_CVC = "cardCvc"
|
|
99
|
+
}
|
|
100
|
+
|
|
62
101
|
export declare const useOpenPayElements: () => ElementsContextValue;
|
|
63
102
|
|
|
64
103
|
export { }
|