@getopenpay/openpay-js-react 0.0.1-alpha.6eb47d5 → 0.0.1-alpha.7d1dabb

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 +43 -11
  2. package/dist/index.js +2014 -1228
  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,5 +1,4 @@
1
1
  import { FC } from 'react';
2
- import { PropsWithChildren } from 'react';
3
2
  import { z } from 'zod';
4
3
 
5
4
  export declare const CardCvcElement: FC<ElementProps>;
@@ -11,29 +10,42 @@ export declare const CardExpiryElement: FC<ElementProps>;
11
10
  export declare const CardNumberElement: FC<ElementProps>;
12
11
 
13
12
  declare type ElementProps = {
14
- styles?: ElementStyle;
13
+ styles?: ElementsStyle;
15
14
  };
16
15
 
17
16
  declare type ElementsContextValue = {
18
- contextId: string;
19
- createToken: () => void;
20
- dispatchEvent: (event: MessageEvent, frame: HTMLIFrameElement) => void;
17
+ formId: string;
21
18
  formHeight: string;
19
+ referer?: string;
20
+ checkoutSecureToken?: string;
21
+ registerIframe: (iframe: HTMLIFrameElement) => void;
22
22
  };
23
23
 
24
24
  export declare const ElementsForm: FC<ElementsFormProps>;
25
25
 
26
- declare interface ElementsFormProps extends PropsWithChildren {
26
+ declare type ElementsFormChildrenProps = {
27
+ submit: () => void;
28
+ };
29
+
30
+ declare type ElementsFormProps = {
27
31
  className?: string;
32
+ checkoutSecureToken?: string;
33
+ children: (props: ElementsFormChildrenProps) => JSX.Element;
28
34
  onFocus?: (elementId: string) => void;
29
35
  onBlur?: (elementId: string) => void;
30
36
  onChange?: (elementId: string) => void;
31
- onValidationError?: (message: string, elementId?: string) => void;
32
- }
33
-
34
- declare type ElementStyle = z.infer<typeof ElementStyleSchema>;
37
+ onLoad?: (totalAmountAtoms: number, currency?: string) => void;
38
+ onLoadError?: (message: string) => void;
39
+ onValidationError?: (field: FieldName, errors: string[], elementId?: string) => void;
40
+ onCheckoutStarted?: () => void;
41
+ onCheckoutSuccess?: (invoiceUrls: string[]) => void;
42
+ onCheckoutError?: (message: string) => void;
43
+ };
35
44
 
36
- declare const ElementStyleSchema: z.ZodObject<{
45
+ /**
46
+ * Styles
47
+ */
48
+ declare const ElementsStyle: z.ZodObject<{
37
49
  backgroundColor: z.ZodOptional<z.ZodString>;
38
50
  color: z.ZodOptional<z.ZodString>;
39
51
  fontFamily: z.ZodOptional<z.ZodString>;
@@ -59,6 +71,26 @@ declare const ElementStyleSchema: z.ZodObject<{
59
71
  padding?: string | undefined;
60
72
  }>;
61
73
 
74
+ declare type ElementsStyle = z.infer<typeof ElementsStyle>;
75
+
76
+ /**
77
+ * Expected input fields
78
+ */
79
+ export declare enum FieldName {
80
+ CARD_NUMBER = "cardNumber",
81
+ CARD_EXPIRY = "cardExpiry",
82
+ CARD_CVC = "cardCvc",
83
+ FIRST_NAME = "firstName",
84
+ LAST_NAME = "lastName",
85
+ EMAIL = "email",
86
+ ZIP_CODE = "zipCode",
87
+ CITY = "city",
88
+ STATE = "state",
89
+ COUNTRY = "country",
90
+ ADDRESS = "address",
91
+ PHONE = "phone"
92
+ }
93
+
62
94
  export declare const useOpenPayElements: () => ElementsContextValue;
63
95
 
64
96
  export { }