@betterstore/react 0.3.42 → 0.3.44
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/CHANGELOG.md +12 -0
- package/dist/components/checkout-embed/appearance.d.ts +4 -3
- package/dist/components/checkout-embed/checkout-form.d.ts +3 -3
- package/dist/components/checkout-embed/index.d.ts +2 -3
- package/dist/components/checkout-embed/steps/payment/form.d.ts +3 -3
- package/dist/components/payment-element/index.d.ts +3 -2
- package/dist/index.cjs.js +14 -11
- package/dist/index.mjs +14 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Appearance as StripeAppearance, StripeElementsOptions } from "@stripe/stripe-js";
|
|
2
2
|
export type Themes = "dark" | "light";
|
|
3
|
+
export type Fonts = StripeElementsOptions["fonts"];
|
|
3
4
|
export type AppearanceConfig = {
|
|
4
5
|
theme?: Themes;
|
|
5
6
|
borderRadius?: number;
|
|
6
7
|
font?: string;
|
|
7
|
-
fontSources?: StripeElementsOptions["fonts"];
|
|
8
8
|
colors?: {
|
|
9
9
|
background?: string;
|
|
10
10
|
foreground?: string;
|
|
@@ -21,7 +21,8 @@ export type AppearanceConfig = {
|
|
|
21
21
|
ring?: string;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
-
export default function Appearance({ appearance, }: {
|
|
24
|
+
export default function Appearance({ appearance, fonts, }: {
|
|
25
25
|
appearance?: AppearanceConfig;
|
|
26
|
+
fonts?: Fonts;
|
|
26
27
|
}): null;
|
|
27
|
-
export declare const convertCheckoutAppearanceToStripeAppearance: (appearance?: AppearanceConfig, fonts?:
|
|
28
|
+
export declare const convertCheckoutAppearanceToStripeAppearance: (appearance?: AppearanceConfig, fonts?: Fonts) => StripeAppearance;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CheckoutSession, createStoreClient } from "@betterstore/sdk";
|
|
2
|
-
import { StripeElementLocale
|
|
2
|
+
import { StripeElementLocale } from "@stripe/stripe-js";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { AppearanceConfig } from "./appearance";
|
|
4
|
+
import { AppearanceConfig, Fonts } from "./appearance";
|
|
5
5
|
interface CheckoutFormProps {
|
|
6
6
|
storeClient: ReturnType<typeof createStoreClient>;
|
|
7
7
|
checkoutId: string;
|
|
@@ -12,7 +12,7 @@ interface CheckoutFormProps {
|
|
|
12
12
|
customer?: CheckoutSession["customer"];
|
|
13
13
|
currency: string;
|
|
14
14
|
checkoutAppearance?: AppearanceConfig;
|
|
15
|
-
fonts?:
|
|
15
|
+
fonts?: Fonts;
|
|
16
16
|
locale?: StripeElementLocale;
|
|
17
17
|
setShippingCost: (cost: number) => void;
|
|
18
18
|
exchangeRate: number;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Locale } from "@/i18n";
|
|
2
|
-
import { StripeElementsOptions } from "@stripe/stripe-js";
|
|
3
2
|
import React from "react";
|
|
4
|
-
import { AppearanceConfig } from "./appearance";
|
|
3
|
+
import { AppearanceConfig, Fonts } from "./appearance";
|
|
5
4
|
interface CheckoutEmbedProps {
|
|
6
5
|
checkoutId: string;
|
|
7
6
|
config: {
|
|
@@ -9,7 +8,7 @@ interface CheckoutEmbedProps {
|
|
|
9
8
|
cancelUrl: string;
|
|
10
9
|
successUrl: string;
|
|
11
10
|
appearance?: AppearanceConfig;
|
|
12
|
-
fonts?:
|
|
11
|
+
fonts?: Fonts;
|
|
13
12
|
locale?: Locale;
|
|
14
13
|
clientProxy?: string;
|
|
15
14
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { StripeElementLocale
|
|
1
|
+
import { StripeElementLocale } from "@stripe/stripe-js";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { AppearanceConfig } from "../../appearance";
|
|
3
|
+
import { AppearanceConfig, Fonts } from "../../appearance";
|
|
4
4
|
interface PaymentFormProps {
|
|
5
5
|
paymentSecret: string | null;
|
|
6
6
|
onSuccess: () => void;
|
|
@@ -12,7 +12,7 @@ interface PaymentFormProps {
|
|
|
12
12
|
shippingName: string;
|
|
13
13
|
shippingPrice: string;
|
|
14
14
|
checkoutAppearance?: AppearanceConfig;
|
|
15
|
-
fonts?:
|
|
15
|
+
fonts?: Fonts;
|
|
16
16
|
locale?: StripeElementLocale;
|
|
17
17
|
publicKey: string | null;
|
|
18
18
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { Appearance, StripeElementLocale
|
|
1
|
+
import { Appearance, StripeElementLocale } from "@stripe/stripe-js";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import { Fonts } from "../checkout-embed/appearance";
|
|
3
4
|
declare function PaymentElement({ paymentSecret, publicKey, checkoutAppearance, locale, fonts, onSuccess, onError, children, setSubmitting, }: {
|
|
4
5
|
paymentSecret: string;
|
|
5
6
|
publicKey: string | null;
|
|
6
7
|
checkoutAppearance?: Appearance;
|
|
7
8
|
locale?: StripeElementLocale;
|
|
8
|
-
fonts?:
|
|
9
|
+
fonts?: Fonts;
|
|
9
10
|
onSuccess?: () => void;
|
|
10
11
|
onError?: () => void;
|
|
11
12
|
children: React.ReactNode;
|
package/dist/index.cjs.js
CHANGED
|
@@ -568,27 +568,30 @@ const appearance = {
|
|
|
568
568
|
variables: {
|
|
569
569
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Geist", "Gill Sans", sans-serif'}};
|
|
570
570
|
|
|
571
|
-
function Appearance({ appearance, }) {
|
|
571
|
+
function Appearance({ appearance, fonts, }) {
|
|
572
572
|
React.useEffect(() => {
|
|
573
|
+
var _a;
|
|
573
574
|
const variables = getVariablesFromAppearanceConfig(appearance);
|
|
574
|
-
|
|
575
|
+
const iframe = document.querySelector("iframe");
|
|
576
|
+
const iframeDoc = (iframe === null || iframe === void 0 ? void 0 : iframe.contentDocument) || ((_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document);
|
|
577
|
+
if (variables && iframeDoc) {
|
|
575
578
|
Object.entries(variables).forEach(([key, value]) => {
|
|
576
|
-
|
|
579
|
+
iframeDoc.documentElement.style.setProperty(key, value);
|
|
577
580
|
});
|
|
578
581
|
}
|
|
579
582
|
// Load fonts if provided
|
|
580
|
-
if (
|
|
581
|
-
|
|
583
|
+
if (fonts && iframeDoc) {
|
|
584
|
+
fonts.forEach((font) => {
|
|
582
585
|
if ("cssSrc" in font) {
|
|
583
586
|
// Handle CSS font source
|
|
584
|
-
const link =
|
|
587
|
+
const link = iframeDoc.createElement("link");
|
|
585
588
|
link.rel = "stylesheet";
|
|
586
589
|
link.href = font.cssSrc;
|
|
587
|
-
|
|
590
|
+
iframeDoc.head.appendChild(link);
|
|
588
591
|
}
|
|
589
592
|
else if ("family" in font) {
|
|
590
593
|
// Handle custom font source
|
|
591
|
-
const style =
|
|
594
|
+
const style = iframeDoc.createElement("style");
|
|
592
595
|
style.textContent = `
|
|
593
596
|
@font-face {
|
|
594
597
|
font-family: '${font.family}';
|
|
@@ -597,11 +600,11 @@ function Appearance({ appearance, }) {
|
|
|
597
600
|
font-style: ${font.style || "normal"};
|
|
598
601
|
}
|
|
599
602
|
`;
|
|
600
|
-
|
|
603
|
+
iframeDoc.head.appendChild(style);
|
|
601
604
|
}
|
|
602
605
|
});
|
|
603
606
|
}
|
|
604
|
-
}, [appearance]);
|
|
607
|
+
}, [appearance, fonts]);
|
|
605
608
|
return null;
|
|
606
609
|
}
|
|
607
610
|
const getVariablesFromAppearanceConfig = (appearance) => {
|
|
@@ -12081,7 +12084,7 @@ function CheckoutEmbedComponent({ checkoutId, config }) {
|
|
|
12081
12084
|
}, []);
|
|
12082
12085
|
return (React.createElement(IframeWrapper, null,
|
|
12083
12086
|
React.createElement("div", { className: "checkout-embed scrollbar-hidden mx-auto max-w-[1200px] min-h-screen overflow-x-hidden gap-6 md:gap-0 py-4 md:py-12 flex flex-col md:grid md:grid-cols-7 " },
|
|
12084
|
-
React.createElement(Appearance, { appearance: appearance }),
|
|
12087
|
+
React.createElement(Appearance, { appearance: appearance, fonts: config.fonts }),
|
|
12085
12088
|
React.createElement("div", { className: "md:col-span-4 px-4 md:px-8" }, loading ? (React.createElement(CheckoutFormLoading, null)) : (React.createElement(CheckoutForm, { locale: locale, setShippingCost: setShippingCost, storeClient: storeClient, fonts: config.fonts, checkoutAppearance: appearance, currency: (_a = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _a !== void 0 ? _a : "", customer: checkout === null || checkout === void 0 ? void 0 : checkout.customer, cancelUrl: cancelUrl, checkoutId: checkoutId, clientSecret: clientSecret, onSuccess: onSuccess, onError: onError, exchangeRate: (_b = checkout === null || checkout === void 0 ? void 0 : checkout.exchangeRate) !== null && _b !== void 0 ? _b : 1, setCheckout: setCheckout, setPublicKey: setPublicKey, publicKey: publicKey, setPaymentSecret: setPaymentSecret, paymentSecret: paymentSecret }))),
|
|
12086
12089
|
React.createElement("div", { className: "md:col-span-3 px-4 md:px-8 order-first md:order-last" },
|
|
12087
12090
|
React.createElement(Toaster, null),
|
package/dist/index.mjs
CHANGED
|
@@ -545,27 +545,30 @@ const appearance = {
|
|
|
545
545
|
variables: {
|
|
546
546
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Geist", "Gill Sans", sans-serif'}};
|
|
547
547
|
|
|
548
|
-
function Appearance({ appearance, }) {
|
|
548
|
+
function Appearance({ appearance, fonts, }) {
|
|
549
549
|
useEffect(() => {
|
|
550
|
+
var _a;
|
|
550
551
|
const variables = getVariablesFromAppearanceConfig(appearance);
|
|
551
|
-
|
|
552
|
+
const iframe = document.querySelector("iframe");
|
|
553
|
+
const iframeDoc = (iframe === null || iframe === void 0 ? void 0 : iframe.contentDocument) || ((_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document);
|
|
554
|
+
if (variables && iframeDoc) {
|
|
552
555
|
Object.entries(variables).forEach(([key, value]) => {
|
|
553
|
-
|
|
556
|
+
iframeDoc.documentElement.style.setProperty(key, value);
|
|
554
557
|
});
|
|
555
558
|
}
|
|
556
559
|
// Load fonts if provided
|
|
557
|
-
if (
|
|
558
|
-
|
|
560
|
+
if (fonts && iframeDoc) {
|
|
561
|
+
fonts.forEach((font) => {
|
|
559
562
|
if ("cssSrc" in font) {
|
|
560
563
|
// Handle CSS font source
|
|
561
|
-
const link =
|
|
564
|
+
const link = iframeDoc.createElement("link");
|
|
562
565
|
link.rel = "stylesheet";
|
|
563
566
|
link.href = font.cssSrc;
|
|
564
|
-
|
|
567
|
+
iframeDoc.head.appendChild(link);
|
|
565
568
|
}
|
|
566
569
|
else if ("family" in font) {
|
|
567
570
|
// Handle custom font source
|
|
568
|
-
const style =
|
|
571
|
+
const style = iframeDoc.createElement("style");
|
|
569
572
|
style.textContent = `
|
|
570
573
|
@font-face {
|
|
571
574
|
font-family: '${font.family}';
|
|
@@ -574,11 +577,11 @@ function Appearance({ appearance, }) {
|
|
|
574
577
|
font-style: ${font.style || "normal"};
|
|
575
578
|
}
|
|
576
579
|
`;
|
|
577
|
-
|
|
580
|
+
iframeDoc.head.appendChild(style);
|
|
578
581
|
}
|
|
579
582
|
});
|
|
580
583
|
}
|
|
581
|
-
}, [appearance]);
|
|
584
|
+
}, [appearance, fonts]);
|
|
582
585
|
return null;
|
|
583
586
|
}
|
|
584
587
|
const getVariablesFromAppearanceConfig = (appearance) => {
|
|
@@ -12058,7 +12061,7 @@ function CheckoutEmbedComponent({ checkoutId, config }) {
|
|
|
12058
12061
|
}, []);
|
|
12059
12062
|
return (React__default.createElement(IframeWrapper, null,
|
|
12060
12063
|
React__default.createElement("div", { className: "checkout-embed scrollbar-hidden mx-auto max-w-[1200px] min-h-screen overflow-x-hidden gap-6 md:gap-0 py-4 md:py-12 flex flex-col md:grid md:grid-cols-7 " },
|
|
12061
|
-
React__default.createElement(Appearance, { appearance: appearance }),
|
|
12064
|
+
React__default.createElement(Appearance, { appearance: appearance, fonts: config.fonts }),
|
|
12062
12065
|
React__default.createElement("div", { className: "md:col-span-4 px-4 md:px-8" }, loading ? (React__default.createElement(CheckoutFormLoading, null)) : (React__default.createElement(CheckoutForm, { locale: locale, setShippingCost: setShippingCost, storeClient: storeClient, fonts: config.fonts, checkoutAppearance: appearance, currency: (_a = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _a !== void 0 ? _a : "", customer: checkout === null || checkout === void 0 ? void 0 : checkout.customer, cancelUrl: cancelUrl, checkoutId: checkoutId, clientSecret: clientSecret, onSuccess: onSuccess, onError: onError, exchangeRate: (_b = checkout === null || checkout === void 0 ? void 0 : checkout.exchangeRate) !== null && _b !== void 0 ? _b : 1, setCheckout: setCheckout, setPublicKey: setPublicKey, publicKey: publicKey, setPaymentSecret: setPaymentSecret, paymentSecret: paymentSecret }))),
|
|
12063
12066
|
React__default.createElement("div", { className: "md:col-span-3 px-4 md:px-8 order-first md:order-last" },
|
|
12064
12067
|
React__default.createElement(Toaster, null),
|