@getopenpay/openpay-js-react 0.0.1-alpha.6eb47d5 → 0.0.2-beta.1

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 +184 -15
  2. package/dist/index.js +870 -786
  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,148 @@
1
1
  import { FC } from 'react';
2
- import { PropsWithChildren } from 'react';
3
2
  import { z } from 'zod';
4
3
 
4
+ export declare const Appearance: z.ZodObject<{
5
+ theme: z.ZodEnum<[AppearanceTheme.UNSTYLED, AppearanceTheme.LIGHT, AppearanceTheme.DARK]>;
6
+ variables: z.ZodOptional<z.ZodObject<{
7
+ colorPrimary: z.ZodOptional<z.ZodString>;
8
+ colorBackground: z.ZodOptional<z.ZodString>;
9
+ colorForeground: z.ZodOptional<z.ZodString>;
10
+ colorText: z.ZodOptional<z.ZodString>;
11
+ colorDanger: z.ZodOptional<z.ZodString>;
12
+ fontFamily: z.ZodOptional<z.ZodString>;
13
+ fontSize: z.ZodOptional<z.ZodString>;
14
+ spacing: z.ZodOptional<z.ZodString>;
15
+ borderRadius: z.ZodOptional<z.ZodString>;
16
+ borderColor: z.ZodOptional<z.ZodString>;
17
+ borderWidth: z.ZodOptional<z.ZodString>;
18
+ focusRingColor: z.ZodOptional<z.ZodString>;
19
+ padding: z.ZodOptional<z.ZodString>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ colorPrimary?: string | undefined;
22
+ colorBackground?: string | undefined;
23
+ colorForeground?: string | undefined;
24
+ colorText?: string | undefined;
25
+ colorDanger?: string | undefined;
26
+ fontFamily?: string | undefined;
27
+ fontSize?: string | undefined;
28
+ spacing?: string | undefined;
29
+ borderRadius?: string | undefined;
30
+ borderColor?: string | undefined;
31
+ borderWidth?: string | undefined;
32
+ focusRingColor?: string | undefined;
33
+ padding?: string | undefined;
34
+ }, {
35
+ colorPrimary?: string | undefined;
36
+ colorBackground?: string | undefined;
37
+ colorForeground?: string | undefined;
38
+ colorText?: string | undefined;
39
+ colorDanger?: string | undefined;
40
+ fontFamily?: string | undefined;
41
+ fontSize?: string | undefined;
42
+ spacing?: string | undefined;
43
+ borderRadius?: string | undefined;
44
+ borderColor?: string | undefined;
45
+ borderWidth?: string | undefined;
46
+ focusRingColor?: string | undefined;
47
+ padding?: string | undefined;
48
+ }>>;
49
+ }, "strip", z.ZodTypeAny, {
50
+ theme: AppearanceTheme;
51
+ variables?: {
52
+ colorPrimary?: string | undefined;
53
+ colorBackground?: string | undefined;
54
+ colorForeground?: string | undefined;
55
+ colorText?: string | undefined;
56
+ colorDanger?: string | undefined;
57
+ fontFamily?: string | undefined;
58
+ fontSize?: string | undefined;
59
+ spacing?: string | undefined;
60
+ borderRadius?: string | undefined;
61
+ borderColor?: string | undefined;
62
+ borderWidth?: string | undefined;
63
+ focusRingColor?: string | undefined;
64
+ padding?: string | undefined;
65
+ } | undefined;
66
+ }, {
67
+ theme: AppearanceTheme;
68
+ variables?: {
69
+ colorPrimary?: string | undefined;
70
+ colorBackground?: string | undefined;
71
+ colorForeground?: string | undefined;
72
+ colorText?: string | undefined;
73
+ colorDanger?: string | undefined;
74
+ fontFamily?: string | undefined;
75
+ fontSize?: string | undefined;
76
+ spacing?: string | undefined;
77
+ borderRadius?: string | undefined;
78
+ borderColor?: string | undefined;
79
+ borderWidth?: string | undefined;
80
+ focusRingColor?: string | undefined;
81
+ padding?: string | undefined;
82
+ } | undefined;
83
+ }>;
84
+
85
+ export declare type Appearance = z.infer<typeof Appearance>;
86
+
87
+ /**
88
+ * Models shared between CDE and OpenPay.js
89
+ * Don't forget to update shared-models.ts in the other repo's utils folder too!
90
+ */
91
+ /**
92
+ * Styles and appearance
93
+ */
94
+ export declare enum AppearanceTheme {
95
+ UNSTYLED = "unstyled",
96
+ LIGHT = "light",
97
+ DARK = "dark"
98
+ }
99
+
100
+ export declare const AppearanceVariables: z.ZodObject<{
101
+ colorPrimary: z.ZodOptional<z.ZodString>;
102
+ colorBackground: z.ZodOptional<z.ZodString>;
103
+ colorForeground: z.ZodOptional<z.ZodString>;
104
+ colorText: z.ZodOptional<z.ZodString>;
105
+ colorDanger: z.ZodOptional<z.ZodString>;
106
+ fontFamily: z.ZodOptional<z.ZodString>;
107
+ fontSize: z.ZodOptional<z.ZodString>;
108
+ spacing: z.ZodOptional<z.ZodString>;
109
+ borderRadius: z.ZodOptional<z.ZodString>;
110
+ borderColor: z.ZodOptional<z.ZodString>;
111
+ borderWidth: z.ZodOptional<z.ZodString>;
112
+ focusRingColor: z.ZodOptional<z.ZodString>;
113
+ padding: z.ZodOptional<z.ZodString>;
114
+ }, "strip", z.ZodTypeAny, {
115
+ colorPrimary?: string | undefined;
116
+ colorBackground?: string | undefined;
117
+ colorForeground?: string | undefined;
118
+ colorText?: string | undefined;
119
+ colorDanger?: string | undefined;
120
+ fontFamily?: string | undefined;
121
+ fontSize?: string | undefined;
122
+ spacing?: string | undefined;
123
+ borderRadius?: string | undefined;
124
+ borderColor?: string | undefined;
125
+ borderWidth?: string | undefined;
126
+ focusRingColor?: string | undefined;
127
+ padding?: string | undefined;
128
+ }, {
129
+ colorPrimary?: string | undefined;
130
+ colorBackground?: string | undefined;
131
+ colorForeground?: string | undefined;
132
+ colorText?: string | undefined;
133
+ colorDanger?: string | undefined;
134
+ fontFamily?: string | undefined;
135
+ fontSize?: string | undefined;
136
+ spacing?: string | undefined;
137
+ borderRadius?: string | undefined;
138
+ borderColor?: string | undefined;
139
+ borderWidth?: string | undefined;
140
+ focusRingColor?: string | undefined;
141
+ padding?: string | undefined;
142
+ }>;
143
+
144
+ export declare type AppearanceVariables = z.infer<typeof AppearanceVariables>;
145
+
5
146
  export declare const CardCvcElement: FC<ElementProps>;
6
147
 
7
148
  export declare const CardElement: FC<ElementProps>;
@@ -11,29 +152,40 @@ export declare const CardExpiryElement: FC<ElementProps>;
11
152
  export declare const CardNumberElement: FC<ElementProps>;
12
153
 
13
154
  declare type ElementProps = {
14
- styles?: ElementStyle;
155
+ styles?: ElementsStyle;
15
156
  };
16
157
 
17
158
  declare type ElementsContextValue = {
18
159
  contextId: string;
19
- createToken: () => void;
20
- dispatchEvent: (event: MessageEvent, frame: HTMLIFrameElement) => void;
21
160
  formHeight: string;
161
+ referer?: string;
162
+ checkoutSecureToken?: string;
163
+ appearance?: Appearance;
22
164
  };
23
165
 
24
166
  export declare const ElementsForm: FC<ElementsFormProps>;
25
167
 
26
- declare interface ElementsFormProps extends PropsWithChildren {
168
+ declare type ElementsFormChildrenProps = {
169
+ submit: () => void;
170
+ };
171
+
172
+ declare type ElementsFormProps = {
27
173
  className?: string;
174
+ appearance?: Appearance;
175
+ checkoutSecureToken?: string;
176
+ children: (props: ElementsFormChildrenProps) => JSX.Element;
28
177
  onFocus?: (elementId: string) => void;
29
178
  onBlur?: (elementId: string) => void;
30
179
  onChange?: (elementId: string) => void;
180
+ onLoad?: (totalAmountAtoms: number) => void;
181
+ onLoadError?: (message: string) => void;
31
182
  onValidationError?: (message: string, elementId?: string) => void;
32
- }
33
-
34
- declare type ElementStyle = z.infer<typeof ElementStyleSchema>;
183
+ onCheckoutStarted?: () => void;
184
+ onCheckoutSuccess?: (invoiceUrls: string[]) => void;
185
+ onCheckoutError?: (message: string) => void;
186
+ };
35
187
 
36
- declare const ElementStyleSchema: z.ZodObject<{
188
+ declare const ElementsStyle: z.ZodObject<{
37
189
  backgroundColor: z.ZodOptional<z.ZodString>;
38
190
  color: z.ZodOptional<z.ZodString>;
39
191
  fontFamily: z.ZodOptional<z.ZodString>;
@@ -42,23 +194,40 @@ declare const ElementStyleSchema: z.ZodObject<{
42
194
  margin: z.ZodOptional<z.ZodString>;
43
195
  padding: z.ZodOptional<z.ZodString>;
44
196
  }, "strip", z.ZodTypeAny, {
45
- backgroundColor?: string | undefined;
46
- color?: string | undefined;
47
197
  fontFamily?: string | undefined;
48
198
  fontSize?: string | undefined;
49
- fontWeight?: string | undefined;
50
- margin?: string | undefined;
51
199
  padding?: string | undefined;
52
- }, {
53
200
  backgroundColor?: string | undefined;
54
201
  color?: string | undefined;
202
+ fontWeight?: string | undefined;
203
+ margin?: string | undefined;
204
+ }, {
55
205
  fontFamily?: string | undefined;
56
206
  fontSize?: string | undefined;
207
+ padding?: string | undefined;
208
+ backgroundColor?: string | undefined;
209
+ color?: string | undefined;
57
210
  fontWeight?: string | undefined;
58
211
  margin?: string | undefined;
59
- padding?: string | undefined;
60
212
  }>;
61
213
 
214
+ declare type ElementsStyle = z.infer<typeof ElementsStyle>;
215
+
216
+ /**
217
+ * Form field names
218
+ */
219
+ export declare enum FieldName {
220
+ FIRST_NAME = "firstName",
221
+ LAST_NAME = "lastName",
222
+ EMAIL = "email",
223
+ ZIP_CODE = "zipCode",
224
+ CITY = "city",
225
+ STATE = "state",
226
+ COUNTRY = "country",
227
+ ADDRESS = "address",
228
+ PHONE = "phone"
229
+ }
230
+
62
231
  export declare const useOpenPayElements: () => ElementsContextValue;
63
232
 
64
233
  export { }