@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.
Files changed (56) hide show
  1. package/dist/index.d.ts +51 -12
  2. package/dist/index.js +853 -730
  3. package/package.json +13 -3
  4. package/.env.development +0 -1
  5. package/.env.production +0 -1
  6. package/.env.staging +0 -1
  7. package/.eslintrc.cjs +0 -18
  8. package/.github/workflows/alpha-release.yml +0 -39
  9. package/.github/workflows/release.yml +0 -30
  10. package/Makefile +0 -37
  11. package/example/.eslintrc.json +0 -3
  12. package/example/Makefile +0 -10
  13. package/example/README.md +0 -36
  14. package/example/next.config.mjs +0 -4
  15. package/example/package-lock.json +0 -5283
  16. package/example/package.json +0 -27
  17. package/example/postcss.config.mjs +0 -8
  18. package/example/public/next.svg +0 -1
  19. package/example/public/vercel.svg +0 -1
  20. package/example/src/app/elements/_components/FormWrapper.tsx +0 -18
  21. package/example/src/app/elements/_components/InputField.tsx +0 -11
  22. package/example/src/app/elements/card/page.tsx +0 -54
  23. package/example/src/app/elements/card-cvc/page.tsx +0 -29
  24. package/example/src/app/elements/card-expiry/page.tsx +0 -29
  25. package/example/src/app/elements/card-number/page.tsx +0 -29
  26. package/example/src/app/favicon.ico +0 -0
  27. package/example/src/app/globals.css +0 -14
  28. package/example/src/app/layout.tsx +0 -22
  29. package/example/src/app/page.tsx +0 -119
  30. package/example/tailwind.config.ts +0 -11
  31. package/example/tsconfig.json +0 -26
  32. package/lib/components/_common/frame.tsx +0 -73
  33. package/lib/components/card-cvc.tsx +0 -11
  34. package/lib/components/card-expiry.tsx +0 -11
  35. package/lib/components/card-number.tsx +0 -11
  36. package/lib/components/card.tsx +0 -11
  37. package/lib/components/form.tsx +0 -100
  38. package/lib/hooks/context.ts +0 -17
  39. package/lib/hooks/use-openpay-elements.ts +0 -12
  40. package/lib/index.ts +0 -16
  41. package/lib/utils/constants.ts +0 -1
  42. package/lib/utils/element.ts +0 -5
  43. package/lib/utils/event.ts +0 -66
  44. package/lib/utils/style.ts +0 -17
  45. package/lib/vite-env.d.ts +0 -1
  46. package/ngrok.example.yml +0 -6
  47. package/playwright.config.ts +0 -37
  48. package/tests/card-cvc.test.ts +0 -68
  49. package/tests/card-element.test.ts +0 -113
  50. package/tests/card-expiry.test.ts +0 -61
  51. package/tests/card-number.test.ts +0 -61
  52. package/tests/constants.ts +0 -97
  53. package/tsconfig.build.json +0 -28
  54. package/tsconfig.json +0 -11
  55. package/tsconfig.node.json +0 -13
  56. 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?: ElementStyle;
16
+ export declare type ElementProps = {
17
+ styles?: ElementsStyle;
15
18
  };
16
19
 
17
20
  declare type ElementsContextValue = {
18
- contextId: string;
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 interface ElementsFormProps extends PropsWithChildren {
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
- onValidationError?: (message: string, elementId?: string) => void;
32
- }
33
-
34
- declare type ElementStyle = z.infer<typeof ElementStyleSchema>;
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
- declare const ElementStyleSchema: z.ZodObject<{
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 { }