@crossmint/client-sdk-react-ui 1.0.1-alpha.5 → 1.1.0-alpha.0

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/package.json CHANGED
@@ -1,22 +1,20 @@
1
1
  {
2
2
  "name": "@crossmint/client-sdk-react-ui",
3
- "version": "1.0.1-alpha.5",
3
+ "version": "1.1.0-alpha.0",
4
4
  "author": "Paella Labs Inc",
5
5
  "license": "Apache-2.0",
6
- "repository": "https://github.com/CrossMint/crossmint-client-sdk",
6
+ "repository": "https://github.com/Crossmint/crossmint-client-sdk",
7
7
  "type": "module",
8
8
  "sideEffects": false,
9
- "main": "lib/index.cjs",
10
- "module": "lib/index.js",
11
- "types": "lib/index.d.ts",
9
+ "main": "./dist/index.cjs",
10
+ "module": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
12
  "exports": {
13
- ".": {
14
- "import": "./lib/index.js",
15
- "require": "./lib/index.cjs"
16
- }
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs"
17
15
  },
18
16
  "files": [
19
- "lib",
17
+ "dist",
20
18
  "src",
21
19
  "LICENSE"
22
20
  ],
@@ -24,31 +22,26 @@
24
22
  "access": "public"
25
23
  },
26
24
  "scripts": {
27
- "create-version-file": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
25
+ "create-version-file": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/consts/version.ts",
28
26
  "version": "yarn run create-version-file && git add .",
29
27
  "prebuild": "yarn run create-version-file",
30
- "clean": "shx rm -rf lib/*",
31
- "build": "yarn clean && tsup src/index.ts --external react,react-dom --format esm,cjs --outDir ./lib --minify --dts",
28
+ "clean": "shx rm -rf dist/*",
29
+ "build": "yarn clean && tsup src/index.ts --external react,react-dom --format esm,cjs --outDir ./dist --minify --dts --sourcemap",
32
30
  "test": "jest"
33
31
  },
34
32
  "dependencies": {
35
- "@crossmint/client-sdk-base": "^1.0.1-alpha.5",
36
- "react-jss": "10.9.2",
37
- "uuid": "^8.3.2"
33
+ "@crossmint/client-sdk-base": "1.1.0-alpha.0",
34
+ "react-jss": "10.10.0"
38
35
  },
39
36
  "peerDependencies": {
40
37
  "react": ">=17.0.2",
41
38
  "react-dom": ">=17.0.2"
42
39
  },
43
40
  "devDependencies": {
44
- "@testing-library/jest-dom": "^5.16.5",
45
- "@types/jest": "^27.4.1",
46
- "@types/react": "17.0.34",
47
- "@types/react-dom": "^17.0.11",
48
- "jest": "^27.5.1",
49
- "node-fetch": "^3.2.0",
50
- "ts-jest": "^27.1.3",
51
- "ts-node-dev": "^1.1.8"
41
+ "@types/react": "18.2.21",
42
+ "@types/react-dom": "18.2.7",
43
+ "react": "18.2.0",
44
+ "react-dom": "18.2.0"
52
45
  },
53
- "gitHead": "8122e1da5afd5e8897ccfcd81d69ea2af42f27e4"
46
+ "gitHead": "7f6af83afdbea094939a79b9eb942eb758a178eb"
54
47
  }
@@ -0,0 +1,34 @@
1
+ import "@testing-library/jest-dom";
2
+ import { render, screen } from "@testing-library/react";
3
+
4
+ import { CrossmintNFTCollectionView } from "./CrossmintNFTCollectionView";
5
+
6
+ const wallets = [{ chain: "solana", publicKey: "12345" }];
7
+
8
+ describe("when only passing mandatory fields", () => {
9
+ test("should add them to the iframe query params", () => {
10
+ render(<CrossmintNFTCollectionView wallets={wallets} />);
11
+ const iframe = screen.getByRole("nft-collection-view");
12
+ const src = iframe.getAttribute("src");
13
+ expect(src).toContain("wallets=%5B%7B%22chain%22%3A%22solana%22%2C%22publicKey%22%3A%2212345%22%7D%5D");
14
+ expect(src).toContain("clientVersion=");
15
+ });
16
+ });
17
+
18
+ describe("when not setting any environment", () => {
19
+ test("should default to production", () => {
20
+ render(<CrossmintNFTCollectionView wallets={wallets} />);
21
+ const iframe = screen.getByRole("nft-collection-view");
22
+ const src = iframe.getAttribute("src");
23
+ expect(src).toContain("https://www.crossmint.com/");
24
+ });
25
+ });
26
+
27
+ describe("when setting the environment to staging", () => {
28
+ test("should use the staging url", () => {
29
+ render(<CrossmintNFTCollectionView wallets={wallets} environment="staging" />);
30
+ const iframe = screen.getByRole("nft-collection-view");
31
+ const src = iframe.getAttribute("src");
32
+ expect(src).toContain("https://staging.crossmint.com/");
33
+ });
34
+ });
@@ -1,12 +1,10 @@
1
- import * as React from "react";
2
-
3
1
  import {
4
2
  NFTCollectionViewProps,
5
3
  assertValidNFTCollectionViewProps,
6
4
  getNFTCollectionViewSrc,
7
5
  } from "@crossmint/client-sdk-base";
8
6
 
9
- import { LIB_VERSION } from "./version";
7
+ import { LIB_VERSION } from "../consts/version";
10
8
 
11
9
  export function CrossmintNFTCollectionView(props: NFTCollectionViewProps) {
12
10
  assertValidNFTCollectionViewProps(props);
@@ -0,0 +1,36 @@
1
+ import "@testing-library/jest-dom";
2
+ import { render, screen } from "@testing-library/react";
3
+
4
+ import { NFT } from "@crossmint/client-sdk-base";
5
+
6
+ import { CrossmintNFTDetail } from "./CrossmintNFTDetail";
7
+
8
+ const nft: NFT = { chain: "ethereum", contractAddress: "0x12345", tokenId: "12" };
9
+
10
+ describe("when only passing mandatory fields", () => {
11
+ test("should add them to the iframe query params", () => {
12
+ render(<CrossmintNFTDetail nft={nft} />);
13
+ const iframe = screen.getByRole("nft-details");
14
+ const src = iframe.getAttribute("src");
15
+ expect(src).toContain("/sdk/wallets/tokens/ethereum:0x12345:12");
16
+ expect(src).toContain("clientVersion=");
17
+ });
18
+ });
19
+
20
+ describe("when not setting any environment", () => {
21
+ test("should default to production", () => {
22
+ render(<CrossmintNFTDetail nft={nft} />);
23
+ const iframe = screen.getByRole("nft-details");
24
+ const src = iframe.getAttribute("src");
25
+ expect(src).toContain("https://www.crossmint.com/");
26
+ });
27
+ });
28
+
29
+ describe("when setting the environment to staging", () => {
30
+ test("should use the staging url", () => {
31
+ render(<CrossmintNFTDetail nft={nft} environment="staging" />);
32
+ const iframe = screen.getByRole("nft-details");
33
+ const src = iframe.getAttribute("src");
34
+ expect(src).toContain("https://staging.crossmint.com/");
35
+ });
36
+ });
@@ -1,8 +1,6 @@
1
- import * as React from "react";
2
-
3
1
  import { NFTDetailProps, assertValidValidateNFTDetailProps, getNFTDetailSrc } from "@crossmint/client-sdk-base";
4
2
 
5
- import { LIB_VERSION } from "./version";
3
+ import { LIB_VERSION } from "../consts/version";
6
4
 
7
5
  export function CrossmintNFTDetail(props: NFTDetailProps) {
8
6
  assertValidValidateNFTDetailProps(props);
@@ -0,0 +1,78 @@
1
+ import "@testing-library/jest-dom";
2
+ import { render, screen } from "@testing-library/react";
3
+
4
+ import { CrossmintEvents } from "@crossmint/client-sdk-base";
5
+
6
+ import { CrossmintPaymentElement } from ".";
7
+
8
+ const embeddedCheckoutProps = {
9
+ clientId: "db218e78-d042-4761-83af-3c4e5e6659dd",
10
+ };
11
+
12
+ describe("CrossmintPaymentElement", () => {
13
+ it("renders an iframe with the correct props", () => {
14
+ render(<CrossmintPaymentElement {...embeddedCheckoutProps} />);
15
+ const iframe = screen.getByRole("crossmint-embedded-checkout.iframe");
16
+
17
+ expect(iframe).toHaveAttribute("src");
18
+ expect(iframe).toHaveAttribute("id", "crossmint-embedded-checkout.iframe");
19
+ expect(iframe).toHaveStyle({
20
+ padding: "0px !important",
21
+ width: "100% !important",
22
+ minWidth: "100% !important",
23
+ overflow: "hidden !important",
24
+ display: "block !important",
25
+ userSelect: "none",
26
+ transform: "translate(0px) !important",
27
+ opacity: "1",
28
+ transition: "ease 0s, opacity 0.4s ease 0.1s",
29
+ });
30
+ });
31
+
32
+ it("calls the onEvent prop when a CrossmintEvents is received", () => {
33
+ const onEvent = jest.fn();
34
+ render(<CrossmintPaymentElement {...embeddedCheckoutProps} onEvent={onEvent} environment="" />);
35
+ screen.getByRole("crossmint-embedded-checkout.iframe");
36
+
37
+ // Simulate receiving a CrossmintEvents message
38
+ const eventData = { type: CrossmintEvents.QUOTE_STATUS_CHANGED, payload: {} };
39
+ const event = new MessageEvent("message", { data: eventData, origin: "https://www.crossmint.com" });
40
+ window.dispatchEvent(event);
41
+
42
+ expect(onEvent).toHaveBeenCalledWith(eventData);
43
+ });
44
+
45
+ it("does not call the onEvent prop when a different origin than the environment is received in the event", () => {
46
+ const onEvent = jest.fn();
47
+ render(<CrossmintPaymentElement {...embeddedCheckoutProps} onEvent={onEvent} environment="" />);
48
+ screen.getByRole("crossmint-embedded-checkout.iframe");
49
+
50
+ // Simulate receiving a CrossmintEvents message
51
+ const eventData = { type: CrossmintEvents.QUOTE_STATUS_CHANGED, payload: {} };
52
+ const event = new MessageEvent("message", { data: eventData, origin: "http://hacker.com" });
53
+ window.dispatchEvent(event);
54
+
55
+ expect(onEvent).not.toHaveBeenCalled();
56
+ });
57
+
58
+ it("should add the `whPassThroughArgs` prop when passed", async () => {
59
+ render(<CrossmintPaymentElement {...embeddedCheckoutProps} whPassThroughArgs={{ hello: "hi" }} />);
60
+ const iframe = screen.getByRole("crossmint-embedded-checkout.iframe");
61
+
62
+ expect(iframe.getAttribute("src")).toContain("whPassThroughArgs=%7B%22hello%22%3A%22hi%22%7D");
63
+ });
64
+
65
+ it("should add the clientId when passing the collectionId prop", () => {
66
+ render(<CrossmintPaymentElement collectionId={embeddedCheckoutProps.clientId} />);
67
+ const iframe = screen.getByRole("crossmint-embedded-checkout.iframe");
68
+
69
+ expect(iframe.getAttribute("src")).toContain(`clientId=${embeddedCheckoutProps.clientId}`);
70
+ });
71
+
72
+ it("should add projectId when added", () => {
73
+ render(<CrossmintPaymentElement collectionId={embeddedCheckoutProps.clientId} projectId="123" />);
74
+ const iframe = screen.getByRole("crossmint-embedded-checkout.iframe");
75
+
76
+ expect(iframe.getAttribute("src")).toContain("projectId=123");
77
+ });
78
+ });
@@ -0,0 +1,13 @@
1
+ import { CryptoEmbeddedCheckoutProps } from "@crossmint/client-sdk-base";
2
+
3
+ import CrossmintEmbeddedCheckoutIFrame from "./EmbeddedCheckoutIFrame";
4
+
5
+ export function CrossmintCryptoEmbeddedCheckout(props: CryptoEmbeddedCheckoutProps) {
6
+ const { signer } = props;
7
+
8
+ if (signer == null) {
9
+ throw new Error("Invalid parameters: signer is required in versions < 2.0.0");
10
+ }
11
+
12
+ return <CrossmintEmbeddedCheckoutIFrame {...props} />;
13
+ }
@@ -0,0 +1,65 @@
1
+ import { useEffect, useState } from "react";
2
+
3
+ import { crossmintIFrameService } from "@crossmint/client-sdk-base";
4
+ import { CrossmintEmbeddedCheckoutProps } from "@crossmint/client-sdk-base";
5
+
6
+ export default function CrossmintEmbeddedCheckoutIFrame(props: CrossmintEmbeddedCheckoutProps) {
7
+ const { getUrl, listenToEvents, listenToInternalEvents } = crossmintIFrameService(props);
8
+
9
+ const [height, setHeight] = useState(0);
10
+ const [url] = useState(getUrl(props));
11
+
12
+ // Public events
13
+ useEffect(() => {
14
+ const clearListener = listenToEvents((event) => {
15
+ props.onEvent?.(event.data);
16
+ });
17
+
18
+ return () => {
19
+ clearListener();
20
+ };
21
+ }, []);
22
+
23
+ // Internal events
24
+ useEffect(() => {
25
+ const clearListener = listenToInternalEvents((event) => {
26
+ const { type, payload } = event.data;
27
+
28
+ switch (type) {
29
+ case "ui:height.changed":
30
+ setHeight(payload.height);
31
+ break;
32
+ default:
33
+ return;
34
+ }
35
+ });
36
+
37
+ return () => {
38
+ clearListener();
39
+ };
40
+ }, []);
41
+
42
+ // TODO: Emit updatable parameters
43
+
44
+ return (
45
+ <iframe
46
+ src={url}
47
+ id="crossmint-embedded-checkout.iframe"
48
+ role="crossmint-embedded-checkout.iframe"
49
+ allow="payment *"
50
+ style={{
51
+ border: "none !important",
52
+ padding: "0px !important",
53
+ width: "100% !important",
54
+ minWidth: "100% !important",
55
+ overflow: "hidden !important",
56
+ display: "block !important",
57
+ userSelect: "none",
58
+ transform: "translate(0px) !important",
59
+ opacity: "1",
60
+ transition: "ease 0s, opacity 0.4s ease 0.1s",
61
+ height: `${height}px`,
62
+ }}
63
+ />
64
+ );
65
+ }
@@ -1,12 +1,12 @@
1
- import React, { useEffect, useState } from "react";
1
+ import { useEffect, useState } from "react";
2
2
 
3
- import type { PaymentElement } from "@crossmint/client-sdk-base";
4
- import { crossmintPaymentService, crossmintUiService } from "@crossmint/client-sdk-base";
3
+ import type { FiatEmbeddedCheckoutProps } from "@crossmint/client-sdk-base";
4
+ import { crossmintPaymentService_OLD, crossmintUiService_OLD } from "@crossmint/client-sdk-base";
5
5
 
6
- export function CrossmintPaymentElement(props: PaymentElement) {
6
+ export function CrossmintFiatPaymentElement_OLD(props: FiatEmbeddedCheckoutProps) {
7
7
  const [height, setHeight] = useState(0);
8
- const { getIframeUrl, listenToEvents, emitQueryParams } = crossmintPaymentService(props);
9
- const { listenToEvents: listenToUiEvents } = crossmintUiService({ environment: props.environment });
8
+ const { getIframeUrl, listenToEvents, emitQueryParams } = crossmintPaymentService_OLD(props);
9
+ const { listenToEvents: listenToUiEvents } = crossmintUiService_OLD({ environment: props.environment });
10
10
  const [url] = useState(getIframeUrl());
11
11
 
12
12
  useEffect(() => {
@@ -51,8 +51,8 @@ export function CrossmintPaymentElement(props: PaymentElement) {
51
51
  return (
52
52
  <iframe
53
53
  src={url}
54
- id="iframe-crossmint-payment-element"
55
- role="iframe-crossmint-payment-element"
54
+ id="crossmint-embedded-checkout.iframe"
55
+ role="crossmint-embedded-checkout.iframe"
56
56
  allow="payment *"
57
57
  style={{
58
58
  border: "none !important",
@@ -0,0 +1,20 @@
1
+ import {
2
+ CrossmintEmbeddedCheckoutProps,
3
+ isCryptoEmbeddedCheckoutProps,
4
+ isFiatEmbeddedCheckoutProps,
5
+ } from "@crossmint/client-sdk-base";
6
+
7
+ import { CrossmintCryptoEmbeddedCheckout } from "./CryptoEmbeddedCheckout";
8
+ import { CrossmintFiatPaymentElement_OLD } from "./FiatPaymentElement_OLD";
9
+
10
+ // TODO: Rename to CrossmintEmbeddedCheckout
11
+ export function CrossmintPaymentElement(props: CrossmintEmbeddedCheckoutProps) {
12
+ if (isFiatEmbeddedCheckoutProps(props)) {
13
+ return <CrossmintFiatPaymentElement_OLD {...props} />;
14
+ }
15
+ if (isCryptoEmbeddedCheckoutProps(props)) {
16
+ throw new Error("Unsupported: Fiat is the only supported payment method.");
17
+ // return <CrossmintCryptoEmbeddedCheckout {...props} />;
18
+ }
19
+ throw new Error("Unsupported: Fiat is the only supported payment method.");
20
+ }
@@ -0,0 +1,187 @@
1
+ import "@testing-library/jest-dom";
2
+ import { act, fireEvent, render, screen } from "@testing-library/react";
3
+
4
+ import { CrossmintPayButton } from ".";
5
+ import { LIB_VERSION } from "../../consts/version";
6
+
7
+ // TODO(#60): create a global service for this to work everywhere and to be able to customize resolved/rejected responses
8
+ const fetchReturns = Promise.resolve({
9
+ json: () => Promise.resolve({}),
10
+ }) as any;
11
+ global.fetch = jest.fn(() => fetchReturns);
12
+
13
+ // TODO(#61): make this automatically mocked in every test suite
14
+ const openReturns = {} as Window;
15
+ global.open = jest.fn(() => openReturns);
16
+ global.console = {
17
+ log: jest.fn(),
18
+ error: jest.fn(),
19
+ warn: jest.fn(),
20
+ } as any;
21
+
22
+ const defaultProps = {
23
+ clientId: "a4e1bfcc-9884-11ec-b909-0242ac120002",
24
+ };
25
+
26
+ afterEach(() => {
27
+ jest.clearAllMocks();
28
+ });
29
+
30
+ describe("CrossmintPayButton", () => {
31
+ test("should open window with correct url", async () => {
32
+ render(<CrossmintPayButton {...defaultProps} />);
33
+
34
+ await act(async () => {
35
+ fireEvent.click(screen.getByText("Buy with credit card"));
36
+ });
37
+
38
+ const urlOrigin = "https://www.crossmint.com";
39
+
40
+ const mintQueryParams = new URLSearchParams({
41
+ clientId: defaultProps.clientId,
42
+ clientName: "client-sdk-react-ui",
43
+ clientVersion: LIB_VERSION,
44
+ locale: "en-US",
45
+ currency: "usd",
46
+ }).toString();
47
+
48
+ const callbackUrl = encodeURIComponent(`${urlOrigin}/checkout/mint?${mintQueryParams}`);
49
+
50
+ const signinURLParams = new URLSearchParams({
51
+ locale: "en-US",
52
+ currency: "usd",
53
+ email: "",
54
+ }).toString();
55
+
56
+ const expectedURL = `${urlOrigin}/signin?${signinURLParams}&callbackUrl=${callbackUrl}`;
57
+ expect(global.open).toHaveBeenCalledWith(
58
+ expectedURL,
59
+ "popUpWindow",
60
+ "height=750,width=400,left=312,top=9,resizable=yes,scrollbars=yes,toolbar=yes,menubar=true,location=no,directories=no, status=yes"
61
+ );
62
+ });
63
+
64
+ test("should add the `whPassThroughArgs` prop on the window url", async () => {
65
+ const whPassThroughArgs = { hello: "hi" };
66
+ render(<CrossmintPayButton {...defaultProps} whPassThroughArgs={whPassThroughArgs} />);
67
+
68
+ await act(async () => {
69
+ fireEvent.click(screen.getByText("Buy with credit card"));
70
+ });
71
+ expect(global.open).toHaveBeenCalledWith(
72
+ expect.stringContaining("whPassThroughArgs%3D%257B%2522hello%2522%253A%2522hi%2522%257D"),
73
+ expect.anything(),
74
+ expect.anything()
75
+ );
76
+ });
77
+
78
+ describe("when passing the prepay prop", () => {
79
+ test("should pass the prepay query param", async () => {
80
+ render(<CrossmintPayButton {...defaultProps} prepay />);
81
+
82
+ await act(async () => {
83
+ fireEvent.click(screen.getByText("Buy with credit card"));
84
+ });
85
+ expect(global.open).toHaveBeenCalledWith(
86
+ expect.stringContaining("prepay%3Dtrue"),
87
+ expect.anything(),
88
+ expect.anything()
89
+ );
90
+ });
91
+ });
92
+
93
+ describe("when passing the prepay prop as false", () => {
94
+ test("should not pass the prepay query param", async () => {
95
+ render(<CrossmintPayButton {...defaultProps} prepay={false} />);
96
+
97
+ await act(async () => {
98
+ fireEvent.click(screen.getByText("Buy with credit card"));
99
+ });
100
+ expect(global.open).toHaveBeenCalledWith(
101
+ expect.not.stringContaining("prepay"),
102
+ expect.anything(),
103
+ expect.anything()
104
+ );
105
+ });
106
+ });
107
+
108
+ describe("when passing the loginEmail prop", () => {
109
+ test("should pass an email in the email query param", async () => {
110
+ render(<CrossmintPayButton {...defaultProps} loginEmail="user@gmail.com" />);
111
+
112
+ await act(async () => {
113
+ fireEvent.click(screen.getByText("Buy with credit card"));
114
+ });
115
+ expect(global.open).toHaveBeenCalledWith(
116
+ expect.stringContaining("email=user%40gmail.com"),
117
+ expect.anything(),
118
+ expect.anything()
119
+ );
120
+ });
121
+
122
+ test("should pass the email query param empty if loginEmail is empty", async () => {
123
+ render(<CrossmintPayButton {...defaultProps} loginEmail="" />);
124
+
125
+ await act(async () => {
126
+ fireEvent.click(screen.getByText("Buy with credit card"));
127
+ });
128
+ expect(global.open).toHaveBeenCalledWith(
129
+ expect.stringContaining("email=&"),
130
+ expect.anything(),
131
+ expect.anything()
132
+ );
133
+ });
134
+
135
+ test("should pass the email query param empty if loginEmail is not present as a param", async () => {
136
+ render(<CrossmintPayButton {...defaultProps} />);
137
+
138
+ await act(async () => {
139
+ fireEvent.click(screen.getByText("Buy with credit card"));
140
+ });
141
+ expect(global.open).toHaveBeenCalledWith(
142
+ expect.stringContaining("email=&"),
143
+ expect.anything(),
144
+ expect.anything()
145
+ );
146
+ });
147
+ });
148
+
149
+ describe("when passing collectionId instead of clientId", () => {
150
+ test("should open window with correct url", async () => {
151
+ render(<CrossmintPayButton collectionId={defaultProps.clientId} />);
152
+
153
+ await act(async () => {
154
+ fireEvent.click(screen.getByText("Buy with credit card"));
155
+ });
156
+
157
+ expect(global.open).toHaveBeenCalledWith(
158
+ expect.stringContaining(`clientId%3D${defaultProps.clientId}`),
159
+ expect.anything(),
160
+ expect.anything()
161
+ );
162
+ });
163
+ });
164
+
165
+ describe("when passing projectId", () => {
166
+ test("should open window with projectId included in query params", async () => {
167
+ render(<CrossmintPayButton {...defaultProps} projectId="123" />);
168
+
169
+ await act(async () => {
170
+ fireEvent.click(screen.getByText("Buy with credit card"));
171
+ });
172
+
173
+ expect(global.open).toHaveBeenCalledWith(
174
+ expect.stringContaining(`projectId%3D123`),
175
+ expect.anything(),
176
+ expect.anything()
177
+ );
178
+ });
179
+ });
180
+
181
+ describe("when passing getButtonText prop", () => {
182
+ test("should show custom text", async () => {
183
+ render(<CrossmintPayButton {...defaultProps} getButtonText={() => "Custom text"} />);
184
+ expect(screen.getByText("Custom text")).toBeInTheDocument();
185
+ });
186
+ });
187
+ });
@@ -1,12 +1,21 @@
1
- import React, { MouseEvent, useMemo } from "react";
1
+ import { CSSProperties, MouseEvent, useMemo } from "react";
2
2
  import { useState } from "react";
3
3
 
4
- import { clientNames, crossmintModalService, crossmintPayButtonService } from "@crossmint/client-sdk-base";
4
+ import {
5
+ CrossmintPayButtonProps,
6
+ clientNames,
7
+ crossmintModalService,
8
+ crossmintPayButtonService,
9
+ } from "@crossmint/client-sdk-base";
5
10
 
11
+ import { LIB_VERSION } from "../../consts/version";
12
+ import useEnvironment from "../../hooks/useEnvironment";
6
13
  import { formatProps, useStyles } from "./styles";
7
- import { CrossmintPayButtonReactProps } from "./types";
8
- import useEnvironment from "./useEnvironment";
9
- import { LIB_VERSION } from "./version";
14
+
15
+ export type CrossmintPayButtonReactProps = CrossmintPayButtonProps & {
16
+ onClick?: (e: MouseEvent<HTMLButtonElement>) => void;
17
+ style?: CSSProperties;
18
+ };
10
19
 
11
20
  export function CrossmintPayButton(buttonProps: CrossmintPayButtonReactProps) {
12
21
  const {
@@ -0,0 +1 @@
1
+ export * from "./CrossmintPayButton";
@@ -8,6 +8,7 @@ interface CustomStylingProps {
8
8
  }
9
9
 
10
10
  const themeIsLight = (theme: string) => theme === "light";
11
+
11
12
  export const formatProps = (theme: string): CustomStylingProps => ({
12
13
  buttonBgColor: themeIsLight(theme) ? "white" : DARK_BG,
13
14
  paragraphColor: themeIsLight(theme) ? "black" : "white",
@@ -0,0 +1,5 @@
1
+ export * from "./CrossmintNFTCollectionView";
2
+ export * from "./CrossmintNFTDetail";
3
+
4
+ export * from "./embed";
5
+ export * from "./hosted";
@@ -0,0 +1 @@
1
+ export const LIB_VERSION = "1.1.0-alpha.0";
@@ -1,10 +1,10 @@
1
- import { useEffect, useState } from "react";
2
-
3
- export default function useEnvironment() {
4
- const [isServerSideRendering, setIsServerSideRendering] = useState(true);
5
- useEffect(() => {
6
- setIsServerSideRendering(false);
7
- }, []);
8
-
9
- return { isServerSideRendering };
10
- }
1
+ import { useEffect, useState } from "react";
2
+
3
+ export default function useEnvironment() {
4
+ const [isServerSideRendering, setIsServerSideRendering] = useState(true);
5
+ useEffect(() => {
6
+ setIsServerSideRendering(false);
7
+ }, []);
8
+
9
+ return { isServerSideRendering };
10
+ }
package/src/index.ts CHANGED
@@ -1,6 +1,4 @@
1
- export * from "./CrossmintPayButton";
2
- export * from "./CrossmintNFTCollectionView";
3
- export * from "./CrossmintNFTDetail";
4
- export * from "./CrossmintPaymentElement";
5
- export { CheckoutEvents, useCrossmintEvents } from "@crossmint/client-sdk-base";
6
- export type { CrossmintCheckoutEvent, CheckoutEventMap, CrossmintCheckoutEventUnion } from "@crossmint/client-sdk-base";
1
+ export * from "./components";
2
+
3
+ export { CrossmintEvents, useCrossmintEvents } from "@crossmint/client-sdk-base";
4
+ export type { CrossmintEvent, CrossmintEventMap } from "@crossmint/client-sdk-base";