@getopenpay/openpay-js-react 0.0.1-alpha.09717a2
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/.env.development +1 -0
- package/.env.production +1 -0
- package/.env.staging +1 -0
- package/.eslintrc.cjs +18 -0
- package/.github/workflows/alpha-release.yml +39 -0
- package/.github/workflows/release.yml +30 -0
- package/Makefile +37 -0
- package/README.md +14 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +3685 -0
- package/example/.eslintrc.json +3 -0
- package/example/Makefile +10 -0
- package/example/README.md +36 -0
- package/example/next.config.mjs +4 -0
- package/example/package-lock.json +5283 -0
- package/example/package.json +27 -0
- package/example/postcss.config.mjs +8 -0
- package/example/public/next.svg +1 -0
- package/example/public/vercel.svg +1 -0
- package/example/src/app/elements/_components/FormWrapper.tsx +18 -0
- package/example/src/app/elements/_components/InputField.tsx +11 -0
- package/example/src/app/elements/card/page.tsx +54 -0
- package/example/src/app/elements/card-cvc/page.tsx +29 -0
- package/example/src/app/elements/card-expiry/page.tsx +29 -0
- package/example/src/app/elements/card-number/page.tsx +29 -0
- package/example/src/app/favicon.ico +0 -0
- package/example/src/app/globals.css +14 -0
- package/example/src/app/layout.tsx +22 -0
- package/example/src/app/page.tsx +119 -0
- package/example/tailwind.config.ts +11 -0
- package/example/tsconfig.json +26 -0
- package/lib/components/_common/frame.tsx +73 -0
- package/lib/components/card-cvc.tsx +11 -0
- package/lib/components/card-expiry.tsx +11 -0
- package/lib/components/card-number.tsx +11 -0
- package/lib/components/card.tsx +11 -0
- package/lib/components/form.tsx +100 -0
- package/lib/hooks/context.ts +17 -0
- package/lib/hooks/use-openpay-elements.ts +12 -0
- package/lib/index.ts +16 -0
- package/lib/utils/constants.ts +1 -0
- package/lib/utils/element.ts +5 -0
- package/lib/utils/event.ts +66 -0
- package/lib/utils/style.ts +17 -0
- package/lib/vite-env.d.ts +1 -0
- package/ngrok.example.yml +6 -0
- package/package.json +44 -0
- package/playwright.config.ts +37 -0
- package/tests/card-cvc.test.ts +68 -0
- package/tests/card-element.test.ts +113 -0
- package/tests/card-expiry.test.ts +61 -0
- package/tests/card-number.test.ts +61 -0
- package/tests/constants.ts +97 -0
- package/tsconfig.build.json +28 -0
- package/tsconfig.json +11 -0
- package/tsconfig.node.json +13 -0
- package/vite.config.ts +36 -0
package/.env.development
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_CDE_BASE_URL = "http://localhost:3030"
|
package/.env.production
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_CDE_BASE_URL = "https://cde.getopenpay.com"
|
package/.env.staging
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_CDE_BASE_URL = "https://cde.openpaystaging.com"
|
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: { browser: true, es2020: true },
|
|
4
|
+
extends: [
|
|
5
|
+
'eslint:recommended',
|
|
6
|
+
'plugin:@typescript-eslint/recommended',
|
|
7
|
+
'plugin:react-hooks/recommended',
|
|
8
|
+
],
|
|
9
|
+
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
|
10
|
+
parser: '@typescript-eslint/parser',
|
|
11
|
+
plugins: ['react-refresh'],
|
|
12
|
+
rules: {
|
|
13
|
+
'react-refresh/only-export-components': [
|
|
14
|
+
'warn',
|
|
15
|
+
{ allowConstantExport: true },
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: 'Publish alpha release'
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
name: 🚀 Publishing to NPM
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v3
|
|
15
|
+
with:
|
|
16
|
+
version: 8
|
|
17
|
+
- uses: actions/setup-node@v3
|
|
18
|
+
with:
|
|
19
|
+
node-version: 22
|
|
20
|
+
registry-url: https://registry.npmjs.org/
|
|
21
|
+
|
|
22
|
+
- name: Set hash and version variable
|
|
23
|
+
# To generate unique hashes for each alpha release without having to change version in package.json
|
|
24
|
+
run: |
|
|
25
|
+
echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
|
26
|
+
echo "VERSION=$(npm view ./ version)" >> $GITHUB_ENV
|
|
27
|
+
|
|
28
|
+
- name: Build package
|
|
29
|
+
run: |
|
|
30
|
+
npm ci
|
|
31
|
+
npm run build:alpha
|
|
32
|
+
# ^ For now to use localhost for cde
|
|
33
|
+
|
|
34
|
+
- name: Publish package
|
|
35
|
+
run: |
|
|
36
|
+
npm version ${{ env.VERSION }}-alpha.${{ env.COMMIT_HASH }} --no-git-tag-version
|
|
37
|
+
npm publish --tag alpha --access public
|
|
38
|
+
env:
|
|
39
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: 'Publish stable release'
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [created]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
name: 🚀 Publishing to NPM
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v3
|
|
14
|
+
with:
|
|
15
|
+
version: 8
|
|
16
|
+
- uses: actions/setup-node@v3
|
|
17
|
+
with:
|
|
18
|
+
node-version: 22
|
|
19
|
+
registry-url: https://registry.npmjs.org/
|
|
20
|
+
|
|
21
|
+
- name: Build package
|
|
22
|
+
run: |
|
|
23
|
+
npm ci
|
|
24
|
+
npm run build
|
|
25
|
+
|
|
26
|
+
- name: Publish package
|
|
27
|
+
run: |
|
|
28
|
+
npm publish --access public
|
|
29
|
+
env:
|
|
30
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
package/Makefile
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.PHONY: install dev start build publish
|
|
2
|
+
|
|
3
|
+
install:
|
|
4
|
+
npm install
|
|
5
|
+
cd example && make install
|
|
6
|
+
npx playwright install --with-deps chromium
|
|
7
|
+
|
|
8
|
+
dev:
|
|
9
|
+
npm run build:dev
|
|
10
|
+
|
|
11
|
+
start: dev
|
|
12
|
+
|
|
13
|
+
build:
|
|
14
|
+
npm run build
|
|
15
|
+
|
|
16
|
+
publish: build
|
|
17
|
+
npm whoami || npm adduser
|
|
18
|
+
npm publish
|
|
19
|
+
|
|
20
|
+
run-example:
|
|
21
|
+
ngrok start --all --config ngrok.yml
|
|
22
|
+
|
|
23
|
+
integration-test: start-ngrok
|
|
24
|
+
sleep 2 && \
|
|
25
|
+
BASE_URL=$$(curl http://localhost:4040/api/tunnels | jq -r ".tunnels[0].public_url") && \
|
|
26
|
+
export BASE_URL=$$BASE_URL && \
|
|
27
|
+
npm run test && \
|
|
28
|
+
make stop-ngrok
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
start-ngrok:
|
|
32
|
+
nohup ngrok start --all --config ngrok.yml > /dev/null &
|
|
33
|
+
|
|
34
|
+
stop-ngrok:
|
|
35
|
+
@echo "Stopping ngrok..."
|
|
36
|
+
@pkill ngrok || true
|
|
37
|
+
@echo "Ngrok stopped."
|
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# openpay-js-react
|
|
2
|
+
|
|
3
|
+
React components for OpenPay.JS
|
|
4
|
+
|
|
5
|
+
## Development
|
|
6
|
+
|
|
7
|
+
1. Install dependencies using `make install`
|
|
8
|
+
2. Run `make dev` to start Vite in watch mode
|
|
9
|
+
3. In another terminal, `cd` into the `example` directory and run `make dev` to start the example app
|
|
10
|
+
4. Open [http://localhost:3032](http://localhost:3032) to see the example app
|
|
11
|
+
|
|
12
|
+
When you make changes to the library, Vite will automatically recompile it and NextJS will automatically reload the page.
|
|
13
|
+
|
|
14
|
+
If NextJS doesn't reload, you can try manually refreshing the page, or reinstalling the library using `npm install ../` in the `example` directory.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
export declare const CardCvcElement: FC<ElementProps>;
|
|
6
|
+
|
|
7
|
+
export declare const CardElement: FC<ElementProps>;
|
|
8
|
+
|
|
9
|
+
export declare const CardExpiryElement: FC<ElementProps>;
|
|
10
|
+
|
|
11
|
+
export declare const CardNumberElement: FC<ElementProps>;
|
|
12
|
+
|
|
13
|
+
declare type ElementProps = {
|
|
14
|
+
styles?: ElementStyle;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
declare type ElementsContextValue = {
|
|
18
|
+
contextId: string;
|
|
19
|
+
createToken: () => void;
|
|
20
|
+
dispatchEvent: (event: MessageEvent, frame: HTMLIFrameElement) => void;
|
|
21
|
+
formHeight: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export declare const ElementsForm: FC<ElementsFormProps>;
|
|
25
|
+
|
|
26
|
+
declare interface ElementsFormProps extends PropsWithChildren {
|
|
27
|
+
className?: string;
|
|
28
|
+
onFocus?: (elementId: string) => void;
|
|
29
|
+
onBlur?: (elementId: string) => void;
|
|
30
|
+
onChange?: (elementId: string) => void;
|
|
31
|
+
onValidationError?: (message: string, elementId?: string) => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare type ElementStyle = z.infer<typeof ElementStyleSchema>;
|
|
35
|
+
|
|
36
|
+
declare const ElementStyleSchema: z.ZodObject<{
|
|
37
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
38
|
+
color: z.ZodOptional<z.ZodString>;
|
|
39
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
40
|
+
fontSize: z.ZodOptional<z.ZodString>;
|
|
41
|
+
fontWeight: z.ZodOptional<z.ZodString>;
|
|
42
|
+
margin: z.ZodOptional<z.ZodString>;
|
|
43
|
+
padding: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
backgroundColor?: string | undefined;
|
|
46
|
+
color?: string | undefined;
|
|
47
|
+
fontFamily?: string | undefined;
|
|
48
|
+
fontSize?: string | undefined;
|
|
49
|
+
fontWeight?: string | undefined;
|
|
50
|
+
margin?: string | undefined;
|
|
51
|
+
padding?: string | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
backgroundColor?: string | undefined;
|
|
54
|
+
color?: string | undefined;
|
|
55
|
+
fontFamily?: string | undefined;
|
|
56
|
+
fontSize?: string | undefined;
|
|
57
|
+
fontWeight?: string | undefined;
|
|
58
|
+
margin?: string | undefined;
|
|
59
|
+
padding?: string | undefined;
|
|
60
|
+
}>;
|
|
61
|
+
|
|
62
|
+
export declare const useOpenPayElements: () => ElementsContextValue;
|
|
63
|
+
|
|
64
|
+
export { }
|