@betterstore/react 0.6.10 → 0.6.12
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/dist/components/checkout-embed/checkout-form.d.ts.map +1 -1
- package/dist/components/checkout-embed/steps/customer/address-utils.d.ts.map +1 -1
- package/dist/components/checkout-embed/steps/payment/form.d.ts +2 -1
- package/dist/components/checkout-embed/steps/payment/form.d.ts.map +1 -1
- package/dist/components/checkout-embed/steps/payment/icons.d.ts +8 -0
- package/dist/components/checkout-embed/steps/payment/icons.d.ts.map +1 -0
- package/dist/components/compounds/form/address-input/index.d.ts.map +1 -1
- package/dist/components/payment-element/checkout-form.d.ts.map +1 -1
- package/dist/components/payment-element/useCheckout.d.ts +3 -0
- package/dist/components/payment-element/useCheckout.d.ts.map +1 -1
- package/dist/index.cjs.js +59 -24
- package/dist/index.mjs +59 -24
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout-form.d.ts","sourceRoot":"","sources":["../../../src/components/checkout-embed/checkout-form.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAGhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAcvD,UAAU,iBAAiB;IACzB,WAAW,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;IACtC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,SAAS,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;CACzC;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,KAAK,EACL,MAAM,EACN,eAAe,EACf,YAAY,EACZ,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,SAAS,EACT,wBAAwB,EACxB,SAAS,GACV,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"checkout-form.d.ts","sourceRoot":"","sources":["../../../src/components/checkout-embed/checkout-form.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAGhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAcvD,UAAU,iBAAiB;IACzB,WAAW,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;IACtC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,SAAS,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;CACzC;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,KAAK,EACL,MAAM,EACN,eAAe,EACf,YAAY,EACZ,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,SAAS,EACT,wBAAwB,EACxB,SAAS,GACV,EAAE,iBAAiB,2CA4SnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/checkout-embed/steps/customer/address-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,eAAO,MAAM,aAAa,GAAI,SAAS,gBAAgB,CAAC,SAAS,CAAC,KAAG,
|
|
1
|
+
{"version":3,"file":"address-utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/checkout-embed/steps/customer/address-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,eAAO,MAAM,aAAa,GAAI,SAAS,gBAAgB,CAAC,SAAS,CAAC,KAAG,MAMpE,CAAC"}
|
|
@@ -15,7 +15,8 @@ interface PaymentFormProps {
|
|
|
15
15
|
locale?: StripeElementLocale;
|
|
16
16
|
publicKey: string | null;
|
|
17
17
|
paymentComponentKey: number;
|
|
18
|
+
currency: string;
|
|
18
19
|
}
|
|
19
|
-
export default function PaymentForm({ paymentSecret, onSuccess, onError, onBack, onDoubleBack, contactEmail, shippingFormData, address, checkoutAppearance, fonts, locale, publicKey, paymentComponentKey, }: PaymentFormProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export default function PaymentForm({ paymentSecret, onSuccess, onError, onBack, onDoubleBack, currency, contactEmail, shippingFormData, address, checkoutAppearance, fonts, locale, publicKey, paymentComponentKey, }: PaymentFormProps): import("react/jsx-runtime").JSX.Element;
|
|
20
21
|
export {};
|
|
21
22
|
//# sourceMappingURL=form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../../../src/components/checkout-embed/steps/payment/form.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../../../src/components/checkout-embed/steps/payment/form.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAIxD,OAAO,EACL,gBAAgB,EAEhB,KAAK,EACN,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,UAAU,gBAAgB;IACxB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;IACjE,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;IACtC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,aAAa,EACb,SAAS,EACT,OAAO,EACP,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,kBAAkB,EAClB,KAAK,EACL,MAAM,EACN,SAAS,EACT,mBAAmB,GACpB,EAAE,gBAAgB,2CA8HlB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type IconProps = React.HTMLAttributes<SVGElement>;
|
|
2
|
+
export declare const Icons: {
|
|
3
|
+
apple: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
google: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
paypal: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=icons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../../../../src/components/checkout-embed/steps/payment/icons.tsx"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;AAElD,eAAO,MAAM,KAAK;mBACD,SAAS;oBA+BR,SAAS;oBAoBT,SAAS;CA6B1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/compounds/form/address-input/index.tsx"],"names":[],"mappings":"AAgBA,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,EAC3B,SAAc,EACd,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,wBAAwB,EACxB,MAAM,GACP,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/compounds/form/address-input/index.tsx"],"names":[],"mappings":"AAgBA,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,EAC3B,SAAc,EACd,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,wBAAwB,EACxB,MAAM,GACP,EAAE,iBAAiB,2CA8TnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout-form.d.ts","sourceRoot":"","sources":["../../../src/components/payment-element/checkout-form.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkout-form.d.ts","sourceRoot":"","sources":["../../../src/components/payment-element/checkout-form.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAyB,MAAM,OAAO,CAAC;qGAQ3C;IACD,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,KAAK,IAAI,CAAC;CACjD;AAqDD,wBAAkC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
type PaymentMethodType = "apple_pay" | "card" | "paypal" | "google_pay" | string | null;
|
|
1
2
|
interface CheckoutStore {
|
|
2
3
|
isSubmitting: boolean;
|
|
3
4
|
setIsSubmitting: (isSubmitting: boolean) => void;
|
|
5
|
+
paymentMethod: PaymentMethodType;
|
|
6
|
+
setPaymentMethod: (paymentMethod: PaymentMethodType) => void;
|
|
4
7
|
}
|
|
5
8
|
export declare const useCheckout: import("zustand").UseBoundStore<import("zustand").StoreApi<CheckoutStore>>;
|
|
6
9
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCheckout.d.ts","sourceRoot":"","sources":["../../../src/components/payment-element/useCheckout.ts"],"names":[],"mappings":"AAEA,UAAU,aAAa;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,CAAC,YAAY,EAAE,OAAO,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"useCheckout.d.ts","sourceRoot":"","sources":["../../../src/components/payment-element/useCheckout.ts"],"names":[],"mappings":"AAEA,KAAK,iBAAiB,GAClB,WAAW,GACX,MAAM,GACN,QAAQ,GACR,YAAY,GACZ,MAAM,GACN,IAAI,CAAC;AAET,UAAU,aAAa;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,CAAC,YAAY,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,aAAa,EAAE,iBAAiB,CAAC;IACjC,gBAAgB,EAAE,CAAC,aAAa,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC9D;AAED,eAAO,MAAM,WAAW,4EAMrB,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -3326,7 +3326,12 @@ const CheckoutEmbed$2 = {
|
|
|
3326
3326
|
loading: "Načítání ...",
|
|
3327
3327
|
Payment: {
|
|
3328
3328
|
back: "Zpět na výběr dopravy",
|
|
3329
|
-
button:
|
|
3329
|
+
button: {
|
|
3330
|
+
"default": "Dokončit objednávku",
|
|
3331
|
+
apple_pay: "Zaplatit s Apple Pay",
|
|
3332
|
+
paypal: "Zaplatit s PayPal",
|
|
3333
|
+
google_pay: "Zaplatit s Google Pay"
|
|
3334
|
+
},
|
|
3330
3335
|
description: "Všechny transakce jsou zabezpečené a šifrované.",
|
|
3331
3336
|
title: "Platba"
|
|
3332
3337
|
},
|
|
@@ -3443,7 +3448,12 @@ const CheckoutEmbed$1 = {
|
|
|
3443
3448
|
title: "Payment",
|
|
3444
3449
|
description: "All transactions are secure and encrypted.",
|
|
3445
3450
|
back: "Back to shipping",
|
|
3446
|
-
button:
|
|
3451
|
+
button: {
|
|
3452
|
+
"default": "Buy now",
|
|
3453
|
+
apple_pay: "Pay with Apple Pay",
|
|
3454
|
+
paypal: "Pay with PayPal",
|
|
3455
|
+
google_pay: "Pay with Google Pay"
|
|
3456
|
+
}
|
|
3447
3457
|
}
|
|
3448
3458
|
};
|
|
3449
3459
|
const Errors = {
|
|
@@ -13695,16 +13705,7 @@ objectType({
|
|
|
13695
13705
|
});
|
|
13696
13706
|
|
|
13697
13707
|
const formatAddress = (address) => {
|
|
13698
|
-
const
|
|
13699
|
-
.filter(Boolean)
|
|
13700
|
-
.join(" ");
|
|
13701
|
-
const parts = [
|
|
13702
|
-
address.line1,
|
|
13703
|
-
address.line2,
|
|
13704
|
-
address.city,
|
|
13705
|
-
partWithoutComma,
|
|
13706
|
-
address.country,
|
|
13707
|
-
].filter(Boolean);
|
|
13708
|
+
const parts = [address.line1, address.zipCode, address.country].filter(Boolean);
|
|
13708
13709
|
return parts.join(", ");
|
|
13709
13710
|
};
|
|
13710
13711
|
|
|
@@ -36302,6 +36303,7 @@ function AddressInput({ className = "", proxy, clientSecret, latitude, longitude
|
|
|
36302
36303
|
const [suggestions, setSuggestions] = React.useState([]);
|
|
36303
36304
|
const [isLoading, setIsLoading] = React.useState(false);
|
|
36304
36305
|
const [isLoadingLookup, setIsLoadingLookup] = React.useState(false);
|
|
36306
|
+
const latestQueryRef = React.useRef("");
|
|
36305
36307
|
const addressInput = form.watch("address.line1") || "";
|
|
36306
36308
|
const cityInput = form.watch("address.city") || "";
|
|
36307
36309
|
const countryCodeInput = form.watch("address.countryCode");
|
|
@@ -36334,6 +36336,7 @@ function AddressInput({ className = "", proxy, clientSecret, latitude, longitude
|
|
|
36334
36336
|
React.useEffect(() => {
|
|
36335
36337
|
if (!showAllInputs && addressInput.length > 2) {
|
|
36336
36338
|
setIsLoading(true);
|
|
36339
|
+
latestQueryRef.current = addressInput;
|
|
36337
36340
|
const fetchSuggestions = () => __awaiter(this, void 0, void 0, function* () {
|
|
36338
36341
|
try {
|
|
36339
36342
|
const countryCode = form.watch("address.countryCode");
|
|
@@ -36345,16 +36348,22 @@ function AddressInput({ className = "", proxy, clientSecret, latitude, longitude
|
|
|
36345
36348
|
locale,
|
|
36346
36349
|
});
|
|
36347
36350
|
console.log(results);
|
|
36348
|
-
|
|
36349
|
-
|
|
36351
|
+
if (latestQueryRef.current === addressInput) {
|
|
36352
|
+
setSuggestions(results);
|
|
36353
|
+
setShowSuggestions(true);
|
|
36354
|
+
}
|
|
36350
36355
|
}
|
|
36351
36356
|
catch (error) {
|
|
36352
|
-
|
|
36353
|
-
|
|
36354
|
-
|
|
36357
|
+
if (latestQueryRef.current === addressInput) {
|
|
36358
|
+
console.error("Error fetching address suggestions:", error);
|
|
36359
|
+
setShowSuggestions(false);
|
|
36360
|
+
setSuggestions([]);
|
|
36361
|
+
}
|
|
36355
36362
|
}
|
|
36356
36363
|
finally {
|
|
36357
|
-
|
|
36364
|
+
if (latestQueryRef.current === addressInput) {
|
|
36365
|
+
setIsLoading(false);
|
|
36366
|
+
}
|
|
36358
36367
|
}
|
|
36359
36368
|
});
|
|
36360
36369
|
fetchSuggestions();
|
|
@@ -36409,7 +36418,7 @@ function AddressInput({ className = "", proxy, clientSecret, latitude, longitude
|
|
|
36409
36418
|
: t("CheckoutEmbed.CustomerForm.address.line1-autocomplete"), required: showAllInputs, icon: jsxRuntime.jsx(Search, { className: "h-4 w-4" }), showIcon: !showAllInputs, onFocus: () => setShowSuggestions(true), onBlur: () => setTimeout(() => setShowSuggestions(false), 200) }), !showAllInputs &&
|
|
36410
36419
|
(showSuggestions || isLoading || isLoadingLookup) && (jsxRuntime.jsx("div", { className: "bg-background border-border absolute left-0 right-0 top-full z-50 mt-1 rounded-md border shadow-lg", "data-dropdown": "suggestions", children: isLoading || isLoadingLookup ? (jsxRuntime.jsxs("div", { className: "text-muted-foreground border-border flex gap-2 border-b p-3 text-sm", children: [isLoadingLookup
|
|
36411
36420
|
? t("CheckoutEmbed.CustomerForm.address.loadingLookup")
|
|
36412
|
-
: t("CheckoutEmbed.CustomerForm.address.loadingSuggestions"), " ", jsxRuntime.jsx(Loader, { className: "size-4 animate-spin" })] })) : suggestions.length > 0 ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: t("CheckoutEmbed.CustomerForm.address.keepTyping") }), jsxRuntime.jsxs("div", { className: "max-h-60 overflow-y-auto", children: [suggestions.map((address, index) => (jsxRuntime.jsx("button", { type: "button", onClick: () => __awaiter(this, void 0, void 0, function* () { return yield handleSelectAddress(address); }), className: "hover:bg-accent border-border flex w-full cursor-pointer items-center border-b px-3 py-3 text-left transition-colors last:border-b-0", children: jsxRuntime.jsx("div", { className: "text-foreground text-sm", children: address.title }) }, index))), jsxRuntime.jsx("button", { type: "button", onClick: handleManualEntry, className: "hover:bg-accent border-border flex w-full cursor-pointer items-center border-b px-3 py-3 text-left transition-colors last:border-b-0", children: jsxRuntime.jsxs("div", { className: "text-muted-foreground flex items-center gap-2 text-sm", children: [t("CheckoutEmbed.CustomerForm.address.enterManually"), " ", jsxRuntime.jsx(ArrowRight, { className: "size-4" })] }) })] })] })) : addressInput.length
|
|
36421
|
+
: t("CheckoutEmbed.CustomerForm.address.loadingSuggestions"), " ", jsxRuntime.jsx(Loader, { className: "size-4 animate-spin" })] })) : suggestions.length > 0 ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: t("CheckoutEmbed.CustomerForm.address.keepTyping") }), jsxRuntime.jsxs("div", { className: "max-h-60 overflow-y-auto", children: [suggestions.map((address, index) => (jsxRuntime.jsx("button", { type: "button", onClick: () => __awaiter(this, void 0, void 0, function* () { return yield handleSelectAddress(address); }), className: "hover:bg-accent border-border flex w-full cursor-pointer items-center border-b px-3 py-3 text-left transition-colors last:border-b-0", children: jsxRuntime.jsx("div", { className: "text-foreground text-sm", children: address.title }) }, index))), jsxRuntime.jsx("button", { type: "button", onClick: handleManualEntry, className: "hover:bg-accent border-border flex w-full cursor-pointer items-center border-b px-3 py-3 text-left transition-colors last:border-b-0", children: jsxRuntime.jsxs("div", { className: "text-muted-foreground flex items-center gap-2 text-sm", children: [t("CheckoutEmbed.CustomerForm.address.enterManually"), " ", jsxRuntime.jsx(ArrowRight, { className: "size-4" })] }) })] })] })) : addressInput.length <= 4 ? (jsxRuntime.jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: t("CheckoutEmbed.CustomerForm.address.keepTyping") })) : (jsxRuntime.jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: t("CheckoutEmbed.CustomerForm.address.noResults") })) }))] }), jsxRuntime.jsx("div", { className: cn(!showAllInputs ? "-mt-2 mb-4 block" : "hidden"), children: jsxRuntime.jsx("button", { type: "button", onClick: handleManualEntry, className: "text-foreground hover:text-muted-foreground cursor-pointer text-[13px] underline", children: t("CheckoutEmbed.CustomerForm.address.enterManually") }) }), jsxRuntime.jsxs("div", { className: cn("space-y-4", !showAllInputs && "-mt-4 h-0 max-h-0 w-0 max-w-0 opacity-0"), children: [jsxRuntime.jsx("div", { className: cn(!showApartmentField ? "block" : "hidden"), children: jsxRuntime.jsxs("button", { type: "button", onClick: () => {
|
|
36413
36422
|
setShowApartmentField(true);
|
|
36414
36423
|
form.setValue("address.line2", "");
|
|
36415
36424
|
form.setFocus("address.line2");
|
|
@@ -37968,13 +37977,19 @@ var loadStripe = function loadStripe() {
|
|
|
37968
37977
|
const useCheckout = create((set) => ({
|
|
37969
37978
|
isSubmitting: false,
|
|
37970
37979
|
setIsSubmitting: (isSubmitting) => set({ isSubmitting }),
|
|
37980
|
+
paymentMethod: null,
|
|
37981
|
+
setPaymentMethod: (paymentMethod) => set({ paymentMethod }),
|
|
37971
37982
|
}));
|
|
37972
37983
|
|
|
37973
37984
|
const CheckoutForm$1 = ({ onSuccess, onError, children, setSubmitting, }) => {
|
|
37974
37985
|
const stripe = reactStripe_umdExports.useStripe();
|
|
37975
37986
|
const elements = reactStripe_umdExports.useElements();
|
|
37976
|
-
const { setIsSubmitting } = useCheckout();
|
|
37987
|
+
const { setIsSubmitting, setPaymentMethod } = useCheckout();
|
|
37977
37988
|
const [errorMessage, setErrorMessage] = React.useState(undefined);
|
|
37989
|
+
const handlePaymentMethodChange = (event) => {
|
|
37990
|
+
var _a, _b;
|
|
37991
|
+
setPaymentMethod((_b = (_a = event === null || event === void 0 ? void 0 : event.value) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : null);
|
|
37992
|
+
};
|
|
37978
37993
|
const handleSubmit = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37979
37994
|
event.preventDefault();
|
|
37980
37995
|
if (!stripe || !elements) {
|
|
@@ -37999,7 +38014,7 @@ const CheckoutForm$1 = ({ onSuccess, onError, children, setSubmitting, }) => {
|
|
|
37999
38014
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
|
|
38000
38015
|
}
|
|
38001
38016
|
});
|
|
38002
|
-
return (jsxRuntime.jsxs("form", { className: "w-full pb-40 sm:pb-0", onSubmit: handleSubmit, children: [jsxRuntime.jsx(reactStripe_umdExports.PaymentElement, {}), errorMessage && (jsxRuntime.jsx("p", { className: "text-destructive -mb-2 mt-2 text-sm", children: errorMessage })), children] }));
|
|
38017
|
+
return (jsxRuntime.jsxs("form", { className: "w-full pb-40 sm:pb-0", onSubmit: handleSubmit, children: [jsxRuntime.jsx(reactStripe_umdExports.PaymentElement, { onChange: handlePaymentMethodChange }), errorMessage && (jsxRuntime.jsx("p", { className: "text-destructive -mb-2 mt-2 text-sm", children: errorMessage })), children] }));
|
|
38003
38018
|
};
|
|
38004
38019
|
var CheckoutForm$2 = React.memo(CheckoutForm$1);
|
|
38005
38020
|
|
|
@@ -42672,10 +42687,30 @@ const convertCheckoutAppearanceToStripeAppearance = (appearance, fonts) => {
|
|
|
42672
42687
|
return newAppearance;
|
|
42673
42688
|
};
|
|
42674
42689
|
|
|
42675
|
-
|
|
42690
|
+
const Icons = {
|
|
42691
|
+
apple: (props) => (jsxRuntime.jsxs("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" }, props, { role: "img", fill: "none", children: [jsxRuntime.jsxs("g", { clipPath: "url(#clip0_4418_8987)", children: [jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M19.1001 19.16C19.6901 18.26 19.9101 17.8 20.3601 16.79C17.0401 15.53 16.5101 10.8 19.7901 8.98999C18.7901 7.72999 17.3801 7 16.0501 7C15.0901 7 14.4301 7.25001 13.8401 7.48001C13.3401 7.67001 12.8901 7.84 12.3301 7.84C11.7301 7.84 11.2001 7.65001 10.6401 7.45001C10.0301 7.23001 9.39006 7 8.59006 7C7.10006 7 5.51007 7.91 4.50007 9.47C3.08007 11.67 3.33007 15.79 5.62007 19.31C6.44007 20.57 7.54007 21.98 8.97007 22C9.57007 22.01 9.96007 21.83 10.3901 21.64C10.8801 21.42 11.4101 21.18 12.3401 21.18C13.2701 21.17 13.7901 21.42 14.2801 21.64C14.7001 21.83 15.0801 22.01 15.6701 22C17.1201 21.98 18.2801 20.42 19.1001 19.16Z", fill: "currentColor" }), jsxRuntime.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M15.8399 2C15.9999 3.1 15.5499 4.19001 14.9599 4.95001C14.3299 5.77001 13.2299 6.41 12.1699 6.37C11.9799 5.31 12.4699 4.21999 13.0699 3.48999C13.7399 2.68999 14.8699 2.07 15.8399 2Z", fill: "currentColor" })] }), jsxRuntime.jsx("defs", { children: jsxRuntime.jsx("clipPath", { id: "clip0_4418_8987", children: jsxRuntime.jsx("rect", { width: "24", height: "24", fill: "white" }) }) })] }))),
|
|
42692
|
+
google: (props) => (jsxRuntime.jsxs("svg", Object.assign({ viewBox: "-3 0 262 262" }, props, { role: "img", fill: "none", children: [jsxRuntime.jsx("path", { d: "M255.878 133.451c0-10.734-.871-18.567-2.756-26.69H130.55v48.448h71.947c-1.45 12.04-9.283 30.172-26.69 42.356l-.244 1.622 38.755 30.023 2.685.268c24.659-22.774 38.875-56.282 38.875-96.027", fill: "#4285F4" }), jsxRuntime.jsx("path", { d: "M130.55 261.1c35.248 0 64.839-11.605 86.453-31.622l-41.196-31.913c-11.024 7.688-25.82 13.055-45.257 13.055-34.523 0-63.824-22.773-74.269-54.25l-1.531.13-40.298 31.187-.527 1.465C35.393 231.798 79.49 261.1 130.55 261.1", fill: "#34A853" }), jsxRuntime.jsx("path", { d: "M56.281 156.37c-2.756-8.123-4.351-16.827-4.351-25.82 0-8.994 1.595-17.697 4.206-25.82l-.073-1.73L15.26 71.312l-1.335.635C5.077 89.644 0 109.517 0 130.55s5.077 40.905 13.925 58.602l42.356-32.782", fill: "#FBBC05" }), jsxRuntime.jsx("path", { d: "M130.55 50.479c24.514 0 41.05 10.589 50.479 19.438l36.844-35.974C195.245 12.91 165.798 0 130.55 0 79.49 0 35.393 29.301 13.925 71.947l42.211 32.783c10.59-31.477 39.891-54.251 74.414-54.251", fill: "#EB4335" })] }))),
|
|
42693
|
+
paypal: (props) => (jsxRuntime.jsx("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "584.798", height: "720", viewBox: "0 0 154.728 190.5" }, props, { role: "img", fill: "none", children: jsxRuntime.jsxs("g", { transform: "translate(898.192 276.071)", children: [jsxRuntime.jsx("path", { clipPath: "none", d: "M-837.663-237.968a5.49 5.49 0 0 0-5.423 4.633l-9.013 57.15-8.281 52.514-.005.044.01-.044 8.281-52.514c.421-2.669 2.719-4.633 5.42-4.633h26.404c26.573 0 49.127-19.387 53.246-45.658.314-1.996.482-3.973.52-5.924v-.003h-.003c-6.753-3.543-14.683-5.565-23.372-5.565z", fill: "#001c64" }), jsxRuntime.jsx("path", { clipPath: "none", d: "M-766.506-232.402c-.037 1.951-.207 3.93-.52 5.926-4.119 26.271-26.673 45.658-53.246 45.658h-26.404c-2.701 0-4.999 1.964-5.42 4.633l-8.281 52.514-5.197 32.947a4.46 4.46 0 0 0 4.405 5.153h28.66a5.49 5.49 0 0 0 5.423-4.633l7.55-47.881c.423-2.669 2.722-4.636 5.423-4.636h16.876c26.573 0 49.124-19.386 53.243-45.655 2.924-18.649-6.46-35.614-22.511-44.026z", fill: "#0070e0" }), jsxRuntime.jsx("path", { clipPath: "none", d: "M-870.225-276.071a5.49 5.49 0 0 0-5.423 4.636l-22.489 142.608a4.46 4.46 0 0 0 4.405 5.156h33.351l8.281-52.514 9.013-57.15a5.49 5.49 0 0 1 5.423-4.633h47.782c8.691 0 16.621 2.025 23.375 5.563.46-23.917-19.275-43.666-46.412-43.666z", fill: "#003087" })] }) }))),
|
|
42694
|
+
};
|
|
42695
|
+
|
|
42696
|
+
function PaymentForm({ paymentSecret, onSuccess, onError, onBack, onDoubleBack, currency, contactEmail, shippingFormData, address, checkoutAppearance, fonts, locale, publicKey, paymentComponentKey, }) {
|
|
42676
42697
|
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
42677
42698
|
const { t } = useTranslation();
|
|
42678
|
-
|
|
42699
|
+
const { paymentMethod } = useCheckout();
|
|
42700
|
+
const submitButtonTextKey = paymentMethod === "apple_pay"
|
|
42701
|
+
? "apple_pay"
|
|
42702
|
+
: paymentMethod === "card"
|
|
42703
|
+
? "default"
|
|
42704
|
+
: paymentMethod === "paypal"
|
|
42705
|
+
? "paypal"
|
|
42706
|
+
: paymentMethod === "google_pay"
|
|
42707
|
+
? "google_pay"
|
|
42708
|
+
: "default";
|
|
42709
|
+
const submitButtonText = t(`CheckoutEmbed.Payment.button.${submitButtonTextKey}`);
|
|
42710
|
+
const renderButtonIcon = () => {
|
|
42711
|
+
return submitButtonTextKey === "apple_pay" ? (jsxRuntime.jsx(Icons.apple, { className: "size-5 max-sm:size-[22px]" })) : submitButtonTextKey === "google_pay" ? (jsxRuntime.jsx(Icons.google, { className: "ml-1 size-4 max-sm:size-5" })) : submitButtonTextKey === "paypal" ? (jsxRuntime.jsx(Icons.paypal, { className: "ml-1 size-4 max-sm:size-5" })) : null;
|
|
42712
|
+
};
|
|
42713
|
+
return (jsxRuntime.jsxs("div", { className: "space-y-6", children: [jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("h2", { className: "mb-2", children: t("CheckoutEmbed.Payment.title") }), jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: t("CheckoutEmbed.Payment.description") })] }), jsxRuntime.jsxs("div", { className: "space-y-2", children: [jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxRuntime.jsxs("p", { children: [jsxRuntime.jsx("span", { className: "font-medium", children: t("CheckoutEmbed.Shipping.contact") }), " ", jsxRuntime.jsx("span", { className: "text-muted-foreground", children: contactEmail })] }), jsxRuntime.jsx(Button, { variant: "link", size: "link", onClick: onDoubleBack, children: t("CheckoutEmbed.Shipping.change") })] }), jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxRuntime.jsxs("p", { children: [jsxRuntime.jsx("span", { className: "font-medium", children: t("CheckoutEmbed.Shipping.address") }), " ", jsxRuntime.jsx("span", { className: "text-muted-foreground", children: address })] }), jsxRuntime.jsx(Button, { variant: "link", size: "link", onClick: onDoubleBack, children: t("CheckoutEmbed.Shipping.change") })] }), jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxRuntime.jsxs("div", { className: "flex gap-1", children: [jsxRuntime.jsx("p", { className: "font-medium", children: t("CheckoutEmbed.Shipping.shipping") }), " ", jsxRuntime.jsx("div", { className: "text-muted-foreground flex flex-col gap-1", children: Object.entries(shippingFormData).map(([id, shipmentFormData]) => (jsxRuntime.jsxs("p", { children: [shipmentFormData.displayName, " \u00B7", " ", formatPrice(shipmentFormData.priceInCents, currency)] }, id))) })] }), jsxRuntime.jsx(Button, { variant: "link", size: "link", onClick: onBack, children: t("CheckoutEmbed.Shipping.change") })] })] }), jsxRuntime.jsx("div", { className: "mt-8", children: paymentSecret && (jsxRuntime.jsx(PaymentElement$1, { fonts: fonts, checkoutAppearance: convertCheckoutAppearanceToStripeAppearance(checkoutAppearance, fonts), locale: locale, paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError, setSubmitting: setIsSubmitting, publicKey: publicKey, children: jsxRuntime.jsx("div", { className: "fixed bottom-0 left-0 right-0 z-50 mt-8 px-4 sm:static sm:px-0", children: jsxRuntime.jsxs("div", { className: "bg-background flex flex-col-reverse items-center justify-between gap-2 pb-4 sm:flex-row sm:bg-transparent sm:pb-0", children: [jsxRuntime.jsxs(Button, { className: "w-full max-sm:hidden sm:w-fit", type: "button", variant: "ghost", onClick: onBack, children: [jsxRuntime.jsx(ChevronLeft, {}), t("CheckoutEmbed.Payment.back")] }), jsxRuntime.jsxs(SubmitButton, { className: "w-full max-sm:h-[52px] max-sm:text-base sm:w-fit", isValid: true, isSubmitting: isSubmitting, children: [submitButtonText, renderButtonIcon()] })] }) }) }, paymentComponentKey)) })] }));
|
|
42679
42714
|
}
|
|
42680
42715
|
|
|
42681
42716
|
function Skeleton(_a) {
|
|
@@ -42991,7 +43026,7 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
|
|
|
42991
43026
|
};
|
|
42992
43027
|
const renderStep = () => {
|
|
42993
43028
|
if (step === "payment" && formData.customer && formData.shipping) {
|
|
42994
|
-
return (jsxRuntime.jsx(PaymentForm, { paymentComponentKey: paymentComponentKey, locale: locale, fonts: fonts, checkoutAppearance: checkoutAppearance, paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError, onBack: handleBack, onDoubleBack: handleDoubleBack, contactEmail: formData.customer.email, address: formatAddress(formData.customer.address), shippingFormData: formData.shipping, publicKey: publicKey }));
|
|
43029
|
+
return (jsxRuntime.jsx(PaymentForm, { paymentComponentKey: paymentComponentKey, locale: locale, fonts: fonts, checkoutAppearance: checkoutAppearance, paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError, onBack: handleBack, onDoubleBack: handleDoubleBack, contactEmail: formData.customer.email, address: formatAddress(formData.customer.address), shippingFormData: formData.shipping, publicKey: publicKey, currency: currency }));
|
|
42995
43030
|
}
|
|
42996
43031
|
if (step === "shipping" && formData.customer) {
|
|
42997
43032
|
return (jsxRuntime.jsx(ShipmentsShippingMethodForm, { setFormData: setFormData, formData: formData, shippingRates: shippingRates, initialData: formData.shipping, onSubmit: handleShippingSubmit, onBack: handleBack, contactEmail: formData.customer.email, shippingAddress: formatAddress(formData.customer.address), currency: currency, exchangeRate: exchangeRate, locale: locale, countryCode: formData.customer.address.countryCode, shipments: shipments }));
|
package/dist/index.mjs
CHANGED
|
@@ -3306,7 +3306,12 @@ const CheckoutEmbed$2 = {
|
|
|
3306
3306
|
loading: "Načítání ...",
|
|
3307
3307
|
Payment: {
|
|
3308
3308
|
back: "Zpět na výběr dopravy",
|
|
3309
|
-
button:
|
|
3309
|
+
button: {
|
|
3310
|
+
"default": "Dokončit objednávku",
|
|
3311
|
+
apple_pay: "Zaplatit s Apple Pay",
|
|
3312
|
+
paypal: "Zaplatit s PayPal",
|
|
3313
|
+
google_pay: "Zaplatit s Google Pay"
|
|
3314
|
+
},
|
|
3310
3315
|
description: "Všechny transakce jsou zabezpečené a šifrované.",
|
|
3311
3316
|
title: "Platba"
|
|
3312
3317
|
},
|
|
@@ -3423,7 +3428,12 @@ const CheckoutEmbed$1 = {
|
|
|
3423
3428
|
title: "Payment",
|
|
3424
3429
|
description: "All transactions are secure and encrypted.",
|
|
3425
3430
|
back: "Back to shipping",
|
|
3426
|
-
button:
|
|
3431
|
+
button: {
|
|
3432
|
+
"default": "Buy now",
|
|
3433
|
+
apple_pay: "Pay with Apple Pay",
|
|
3434
|
+
paypal: "Pay with PayPal",
|
|
3435
|
+
google_pay: "Pay with Google Pay"
|
|
3436
|
+
}
|
|
3427
3437
|
}
|
|
3428
3438
|
};
|
|
3429
3439
|
const Errors = {
|
|
@@ -13675,16 +13685,7 @@ objectType({
|
|
|
13675
13685
|
});
|
|
13676
13686
|
|
|
13677
13687
|
const formatAddress = (address) => {
|
|
13678
|
-
const
|
|
13679
|
-
.filter(Boolean)
|
|
13680
|
-
.join(" ");
|
|
13681
|
-
const parts = [
|
|
13682
|
-
address.line1,
|
|
13683
|
-
address.line2,
|
|
13684
|
-
address.city,
|
|
13685
|
-
partWithoutComma,
|
|
13686
|
-
address.country,
|
|
13687
|
-
].filter(Boolean);
|
|
13688
|
+
const parts = [address.line1, address.zipCode, address.country].filter(Boolean);
|
|
13688
13689
|
return parts.join(", ");
|
|
13689
13690
|
};
|
|
13690
13691
|
|
|
@@ -36282,6 +36283,7 @@ function AddressInput({ className = "", proxy, clientSecret, latitude, longitude
|
|
|
36282
36283
|
const [suggestions, setSuggestions] = useState([]);
|
|
36283
36284
|
const [isLoading, setIsLoading] = useState(false);
|
|
36284
36285
|
const [isLoadingLookup, setIsLoadingLookup] = useState(false);
|
|
36286
|
+
const latestQueryRef = useRef("");
|
|
36285
36287
|
const addressInput = form.watch("address.line1") || "";
|
|
36286
36288
|
const cityInput = form.watch("address.city") || "";
|
|
36287
36289
|
const countryCodeInput = form.watch("address.countryCode");
|
|
@@ -36314,6 +36316,7 @@ function AddressInput({ className = "", proxy, clientSecret, latitude, longitude
|
|
|
36314
36316
|
useEffect(() => {
|
|
36315
36317
|
if (!showAllInputs && addressInput.length > 2) {
|
|
36316
36318
|
setIsLoading(true);
|
|
36319
|
+
latestQueryRef.current = addressInput;
|
|
36317
36320
|
const fetchSuggestions = () => __awaiter(this, void 0, void 0, function* () {
|
|
36318
36321
|
try {
|
|
36319
36322
|
const countryCode = form.watch("address.countryCode");
|
|
@@ -36325,16 +36328,22 @@ function AddressInput({ className = "", proxy, clientSecret, latitude, longitude
|
|
|
36325
36328
|
locale,
|
|
36326
36329
|
});
|
|
36327
36330
|
console.log(results);
|
|
36328
|
-
|
|
36329
|
-
|
|
36331
|
+
if (latestQueryRef.current === addressInput) {
|
|
36332
|
+
setSuggestions(results);
|
|
36333
|
+
setShowSuggestions(true);
|
|
36334
|
+
}
|
|
36330
36335
|
}
|
|
36331
36336
|
catch (error) {
|
|
36332
|
-
|
|
36333
|
-
|
|
36334
|
-
|
|
36337
|
+
if (latestQueryRef.current === addressInput) {
|
|
36338
|
+
console.error("Error fetching address suggestions:", error);
|
|
36339
|
+
setShowSuggestions(false);
|
|
36340
|
+
setSuggestions([]);
|
|
36341
|
+
}
|
|
36335
36342
|
}
|
|
36336
36343
|
finally {
|
|
36337
|
-
|
|
36344
|
+
if (latestQueryRef.current === addressInput) {
|
|
36345
|
+
setIsLoading(false);
|
|
36346
|
+
}
|
|
36338
36347
|
}
|
|
36339
36348
|
});
|
|
36340
36349
|
fetchSuggestions();
|
|
@@ -36389,7 +36398,7 @@ function AddressInput({ className = "", proxy, clientSecret, latitude, longitude
|
|
|
36389
36398
|
: t("CheckoutEmbed.CustomerForm.address.line1-autocomplete"), required: showAllInputs, icon: jsx(Search, { className: "h-4 w-4" }), showIcon: !showAllInputs, onFocus: () => setShowSuggestions(true), onBlur: () => setTimeout(() => setShowSuggestions(false), 200) }), !showAllInputs &&
|
|
36390
36399
|
(showSuggestions || isLoading || isLoadingLookup) && (jsx("div", { className: "bg-background border-border absolute left-0 right-0 top-full z-50 mt-1 rounded-md border shadow-lg", "data-dropdown": "suggestions", children: isLoading || isLoadingLookup ? (jsxs("div", { className: "text-muted-foreground border-border flex gap-2 border-b p-3 text-sm", children: [isLoadingLookup
|
|
36391
36400
|
? t("CheckoutEmbed.CustomerForm.address.loadingLookup")
|
|
36392
|
-
: t("CheckoutEmbed.CustomerForm.address.loadingSuggestions"), " ", jsx(Loader, { className: "size-4 animate-spin" })] })) : suggestions.length > 0 ? (jsxs(Fragment, { children: [jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: t("CheckoutEmbed.CustomerForm.address.keepTyping") }), jsxs("div", { className: "max-h-60 overflow-y-auto", children: [suggestions.map((address, index) => (jsx("button", { type: "button", onClick: () => __awaiter(this, void 0, void 0, function* () { return yield handleSelectAddress(address); }), className: "hover:bg-accent border-border flex w-full cursor-pointer items-center border-b px-3 py-3 text-left transition-colors last:border-b-0", children: jsx("div", { className: "text-foreground text-sm", children: address.title }) }, index))), jsx("button", { type: "button", onClick: handleManualEntry, className: "hover:bg-accent border-border flex w-full cursor-pointer items-center border-b px-3 py-3 text-left transition-colors last:border-b-0", children: jsxs("div", { className: "text-muted-foreground flex items-center gap-2 text-sm", children: [t("CheckoutEmbed.CustomerForm.address.enterManually"), " ", jsx(ArrowRight, { className: "size-4" })] }) })] })] })) : addressInput.length
|
|
36401
|
+
: t("CheckoutEmbed.CustomerForm.address.loadingSuggestions"), " ", jsx(Loader, { className: "size-4 animate-spin" })] })) : suggestions.length > 0 ? (jsxs(Fragment, { children: [jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: t("CheckoutEmbed.CustomerForm.address.keepTyping") }), jsxs("div", { className: "max-h-60 overflow-y-auto", children: [suggestions.map((address, index) => (jsx("button", { type: "button", onClick: () => __awaiter(this, void 0, void 0, function* () { return yield handleSelectAddress(address); }), className: "hover:bg-accent border-border flex w-full cursor-pointer items-center border-b px-3 py-3 text-left transition-colors last:border-b-0", children: jsx("div", { className: "text-foreground text-sm", children: address.title }) }, index))), jsx("button", { type: "button", onClick: handleManualEntry, className: "hover:bg-accent border-border flex w-full cursor-pointer items-center border-b px-3 py-3 text-left transition-colors last:border-b-0", children: jsxs("div", { className: "text-muted-foreground flex items-center gap-2 text-sm", children: [t("CheckoutEmbed.CustomerForm.address.enterManually"), " ", jsx(ArrowRight, { className: "size-4" })] }) })] })] })) : addressInput.length <= 4 ? (jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: t("CheckoutEmbed.CustomerForm.address.keepTyping") })) : (jsx("div", { className: "text-muted-foreground border-border border-b p-3 text-sm", children: t("CheckoutEmbed.CustomerForm.address.noResults") })) }))] }), jsx("div", { className: cn(!showAllInputs ? "-mt-2 mb-4 block" : "hidden"), children: jsx("button", { type: "button", onClick: handleManualEntry, className: "text-foreground hover:text-muted-foreground cursor-pointer text-[13px] underline", children: t("CheckoutEmbed.CustomerForm.address.enterManually") }) }), jsxs("div", { className: cn("space-y-4", !showAllInputs && "-mt-4 h-0 max-h-0 w-0 max-w-0 opacity-0"), children: [jsx("div", { className: cn(!showApartmentField ? "block" : "hidden"), children: jsxs("button", { type: "button", onClick: () => {
|
|
36393
36402
|
setShowApartmentField(true);
|
|
36394
36403
|
form.setValue("address.line2", "");
|
|
36395
36404
|
form.setFocus("address.line2");
|
|
@@ -37948,13 +37957,19 @@ var loadStripe = function loadStripe() {
|
|
|
37948
37957
|
const useCheckout = create((set) => ({
|
|
37949
37958
|
isSubmitting: false,
|
|
37950
37959
|
setIsSubmitting: (isSubmitting) => set({ isSubmitting }),
|
|
37960
|
+
paymentMethod: null,
|
|
37961
|
+
setPaymentMethod: (paymentMethod) => set({ paymentMethod }),
|
|
37951
37962
|
}));
|
|
37952
37963
|
|
|
37953
37964
|
const CheckoutForm$2 = ({ onSuccess, onError, children, setSubmitting, }) => {
|
|
37954
37965
|
const stripe = reactStripe_umdExports.useStripe();
|
|
37955
37966
|
const elements = reactStripe_umdExports.useElements();
|
|
37956
|
-
const { setIsSubmitting } = useCheckout();
|
|
37967
|
+
const { setIsSubmitting, setPaymentMethod } = useCheckout();
|
|
37957
37968
|
const [errorMessage, setErrorMessage] = useState(undefined);
|
|
37969
|
+
const handlePaymentMethodChange = (event) => {
|
|
37970
|
+
var _a, _b;
|
|
37971
|
+
setPaymentMethod((_b = (_a = event === null || event === void 0 ? void 0 : event.value) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : null);
|
|
37972
|
+
};
|
|
37958
37973
|
const handleSubmit = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37959
37974
|
event.preventDefault();
|
|
37960
37975
|
if (!stripe || !elements) {
|
|
@@ -37979,7 +37994,7 @@ const CheckoutForm$2 = ({ onSuccess, onError, children, setSubmitting, }) => {
|
|
|
37979
37994
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
|
|
37980
37995
|
}
|
|
37981
37996
|
});
|
|
37982
|
-
return (jsxs("form", { className: "w-full pb-40 sm:pb-0", onSubmit: handleSubmit, children: [jsx(reactStripe_umdExports.PaymentElement, {}), errorMessage && (jsx("p", { className: "text-destructive -mb-2 mt-2 text-sm", children: errorMessage })), children] }));
|
|
37997
|
+
return (jsxs("form", { className: "w-full pb-40 sm:pb-0", onSubmit: handleSubmit, children: [jsx(reactStripe_umdExports.PaymentElement, { onChange: handlePaymentMethodChange }), errorMessage && (jsx("p", { className: "text-destructive -mb-2 mt-2 text-sm", children: errorMessage })), children] }));
|
|
37983
37998
|
};
|
|
37984
37999
|
var CheckoutForm$1 = memo(CheckoutForm$2);
|
|
37985
38000
|
|
|
@@ -42652,10 +42667,30 @@ const convertCheckoutAppearanceToStripeAppearance = (appearance, fonts) => {
|
|
|
42652
42667
|
return newAppearance;
|
|
42653
42668
|
};
|
|
42654
42669
|
|
|
42655
|
-
|
|
42670
|
+
const Icons = {
|
|
42671
|
+
apple: (props) => (jsxs("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" }, props, { role: "img", fill: "none", children: [jsxs("g", { clipPath: "url(#clip0_4418_8987)", children: [jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M19.1001 19.16C19.6901 18.26 19.9101 17.8 20.3601 16.79C17.0401 15.53 16.5101 10.8 19.7901 8.98999C18.7901 7.72999 17.3801 7 16.0501 7C15.0901 7 14.4301 7.25001 13.8401 7.48001C13.3401 7.67001 12.8901 7.84 12.3301 7.84C11.7301 7.84 11.2001 7.65001 10.6401 7.45001C10.0301 7.23001 9.39006 7 8.59006 7C7.10006 7 5.51007 7.91 4.50007 9.47C3.08007 11.67 3.33007 15.79 5.62007 19.31C6.44007 20.57 7.54007 21.98 8.97007 22C9.57007 22.01 9.96007 21.83 10.3901 21.64C10.8801 21.42 11.4101 21.18 12.3401 21.18C13.2701 21.17 13.7901 21.42 14.2801 21.64C14.7001 21.83 15.0801 22.01 15.6701 22C17.1201 21.98 18.2801 20.42 19.1001 19.16Z", fill: "currentColor" }), jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M15.8399 2C15.9999 3.1 15.5499 4.19001 14.9599 4.95001C14.3299 5.77001 13.2299 6.41 12.1699 6.37C11.9799 5.31 12.4699 4.21999 13.0699 3.48999C13.7399 2.68999 14.8699 2.07 15.8399 2Z", fill: "currentColor" })] }), jsx("defs", { children: jsx("clipPath", { id: "clip0_4418_8987", children: jsx("rect", { width: "24", height: "24", fill: "white" }) }) })] }))),
|
|
42672
|
+
google: (props) => (jsxs("svg", Object.assign({ viewBox: "-3 0 262 262" }, props, { role: "img", fill: "none", children: [jsx("path", { d: "M255.878 133.451c0-10.734-.871-18.567-2.756-26.69H130.55v48.448h71.947c-1.45 12.04-9.283 30.172-26.69 42.356l-.244 1.622 38.755 30.023 2.685.268c24.659-22.774 38.875-56.282 38.875-96.027", fill: "#4285F4" }), jsx("path", { d: "M130.55 261.1c35.248 0 64.839-11.605 86.453-31.622l-41.196-31.913c-11.024 7.688-25.82 13.055-45.257 13.055-34.523 0-63.824-22.773-74.269-54.25l-1.531.13-40.298 31.187-.527 1.465C35.393 231.798 79.49 261.1 130.55 261.1", fill: "#34A853" }), jsx("path", { d: "M56.281 156.37c-2.756-8.123-4.351-16.827-4.351-25.82 0-8.994 1.595-17.697 4.206-25.82l-.073-1.73L15.26 71.312l-1.335.635C5.077 89.644 0 109.517 0 130.55s5.077 40.905 13.925 58.602l42.356-32.782", fill: "#FBBC05" }), jsx("path", { d: "M130.55 50.479c24.514 0 41.05 10.589 50.479 19.438l36.844-35.974C195.245 12.91 165.798 0 130.55 0 79.49 0 35.393 29.301 13.925 71.947l42.211 32.783c10.59-31.477 39.891-54.251 74.414-54.251", fill: "#EB4335" })] }))),
|
|
42673
|
+
paypal: (props) => (jsx("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "584.798", height: "720", viewBox: "0 0 154.728 190.5" }, props, { role: "img", fill: "none", children: jsxs("g", { transform: "translate(898.192 276.071)", children: [jsx("path", { clipPath: "none", d: "M-837.663-237.968a5.49 5.49 0 0 0-5.423 4.633l-9.013 57.15-8.281 52.514-.005.044.01-.044 8.281-52.514c.421-2.669 2.719-4.633 5.42-4.633h26.404c26.573 0 49.127-19.387 53.246-45.658.314-1.996.482-3.973.52-5.924v-.003h-.003c-6.753-3.543-14.683-5.565-23.372-5.565z", fill: "#001c64" }), jsx("path", { clipPath: "none", d: "M-766.506-232.402c-.037 1.951-.207 3.93-.52 5.926-4.119 26.271-26.673 45.658-53.246 45.658h-26.404c-2.701 0-4.999 1.964-5.42 4.633l-8.281 52.514-5.197 32.947a4.46 4.46 0 0 0 4.405 5.153h28.66a5.49 5.49 0 0 0 5.423-4.633l7.55-47.881c.423-2.669 2.722-4.636 5.423-4.636h16.876c26.573 0 49.124-19.386 53.243-45.655 2.924-18.649-6.46-35.614-22.511-44.026z", fill: "#0070e0" }), jsx("path", { clipPath: "none", d: "M-870.225-276.071a5.49 5.49 0 0 0-5.423 4.636l-22.489 142.608a4.46 4.46 0 0 0 4.405 5.156h33.351l8.281-52.514 9.013-57.15a5.49 5.49 0 0 1 5.423-4.633h47.782c8.691 0 16.621 2.025 23.375 5.563.46-23.917-19.275-43.666-46.412-43.666z", fill: "#003087" })] }) }))),
|
|
42674
|
+
};
|
|
42675
|
+
|
|
42676
|
+
function PaymentForm({ paymentSecret, onSuccess, onError, onBack, onDoubleBack, currency, contactEmail, shippingFormData, address, checkoutAppearance, fonts, locale, publicKey, paymentComponentKey, }) {
|
|
42656
42677
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
42657
42678
|
const { t } = useTranslation();
|
|
42658
|
-
|
|
42679
|
+
const { paymentMethod } = useCheckout();
|
|
42680
|
+
const submitButtonTextKey = paymentMethod === "apple_pay"
|
|
42681
|
+
? "apple_pay"
|
|
42682
|
+
: paymentMethod === "card"
|
|
42683
|
+
? "default"
|
|
42684
|
+
: paymentMethod === "paypal"
|
|
42685
|
+
? "paypal"
|
|
42686
|
+
: paymentMethod === "google_pay"
|
|
42687
|
+
? "google_pay"
|
|
42688
|
+
: "default";
|
|
42689
|
+
const submitButtonText = t(`CheckoutEmbed.Payment.button.${submitButtonTextKey}`);
|
|
42690
|
+
const renderButtonIcon = () => {
|
|
42691
|
+
return submitButtonTextKey === "apple_pay" ? (jsx(Icons.apple, { className: "size-5 max-sm:size-[22px]" })) : submitButtonTextKey === "google_pay" ? (jsx(Icons.google, { className: "ml-1 size-4 max-sm:size-5" })) : submitButtonTextKey === "paypal" ? (jsx(Icons.paypal, { className: "ml-1 size-4 max-sm:size-5" })) : null;
|
|
42692
|
+
};
|
|
42693
|
+
return (jsxs("div", { className: "space-y-6", children: [jsxs("div", { children: [jsx("h2", { className: "mb-2", children: t("CheckoutEmbed.Payment.title") }), jsx("p", { className: "text-muted-foreground text-sm", children: t("CheckoutEmbed.Payment.description") })] }), jsxs("div", { className: "space-y-2", children: [jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxs("p", { children: [jsx("span", { className: "font-medium", children: t("CheckoutEmbed.Shipping.contact") }), " ", jsx("span", { className: "text-muted-foreground", children: contactEmail })] }), jsx(Button, { variant: "link", size: "link", onClick: onDoubleBack, children: t("CheckoutEmbed.Shipping.change") })] }), jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxs("p", { children: [jsx("span", { className: "font-medium", children: t("CheckoutEmbed.Shipping.address") }), " ", jsx("span", { className: "text-muted-foreground", children: address })] }), jsx(Button, { variant: "link", size: "link", onClick: onDoubleBack, children: t("CheckoutEmbed.Shipping.change") })] }), jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxs("div", { className: "flex gap-1", children: [jsx("p", { className: "font-medium", children: t("CheckoutEmbed.Shipping.shipping") }), " ", jsx("div", { className: "text-muted-foreground flex flex-col gap-1", children: Object.entries(shippingFormData).map(([id, shipmentFormData]) => (jsxs("p", { children: [shipmentFormData.displayName, " \u00B7", " ", formatPrice(shipmentFormData.priceInCents, currency)] }, id))) })] }), jsx(Button, { variant: "link", size: "link", onClick: onBack, children: t("CheckoutEmbed.Shipping.change") })] })] }), jsx("div", { className: "mt-8", children: paymentSecret && (jsx(PaymentElement, { fonts: fonts, checkoutAppearance: convertCheckoutAppearanceToStripeAppearance(checkoutAppearance, fonts), locale: locale, paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError, setSubmitting: setIsSubmitting, publicKey: publicKey, children: jsx("div", { className: "fixed bottom-0 left-0 right-0 z-50 mt-8 px-4 sm:static sm:px-0", children: jsxs("div", { className: "bg-background flex flex-col-reverse items-center justify-between gap-2 pb-4 sm:flex-row sm:bg-transparent sm:pb-0", children: [jsxs(Button, { className: "w-full max-sm:hidden sm:w-fit", type: "button", variant: "ghost", onClick: onBack, children: [jsx(ChevronLeft, {}), t("CheckoutEmbed.Payment.back")] }), jsxs(SubmitButton, { className: "w-full max-sm:h-[52px] max-sm:text-base sm:w-fit", isValid: true, isSubmitting: isSubmitting, children: [submitButtonText, renderButtonIcon()] })] }) }) }, paymentComponentKey)) })] }));
|
|
42659
42694
|
}
|
|
42660
42695
|
|
|
42661
42696
|
function Skeleton(_a) {
|
|
@@ -42971,7 +43006,7 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
|
|
|
42971
43006
|
};
|
|
42972
43007
|
const renderStep = () => {
|
|
42973
43008
|
if (step === "payment" && formData.customer && formData.shipping) {
|
|
42974
|
-
return (jsx(PaymentForm, { paymentComponentKey: paymentComponentKey, locale: locale, fonts: fonts, checkoutAppearance: checkoutAppearance, paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError, onBack: handleBack, onDoubleBack: handleDoubleBack, contactEmail: formData.customer.email, address: formatAddress(formData.customer.address), shippingFormData: formData.shipping, publicKey: publicKey }));
|
|
43009
|
+
return (jsx(PaymentForm, { paymentComponentKey: paymentComponentKey, locale: locale, fonts: fonts, checkoutAppearance: checkoutAppearance, paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError, onBack: handleBack, onDoubleBack: handleDoubleBack, contactEmail: formData.customer.email, address: formatAddress(formData.customer.address), shippingFormData: formData.shipping, publicKey: publicKey, currency: currency }));
|
|
42975
43010
|
}
|
|
42976
43011
|
if (step === "shipping" && formData.customer) {
|
|
42977
43012
|
return (jsx(ShipmentsShippingMethodForm, { setFormData: setFormData, formData: formData, shippingRates: shippingRates, initialData: formData.shipping, onSubmit: handleShippingSubmit, onBack: handleBack, contactEmail: formData.customer.email, shippingAddress: formatAddress(formData.customer.address), currency: currency, exchangeRate: exchangeRate, locale: locale, countryCode: formData.customer.address.countryCode, shipments: shipments }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betterstore/react",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.12",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"world_countries_lists": "^3.2.0",
|
|
78
78
|
"zod": "^3.25.30",
|
|
79
79
|
"zustand": "^5.0.5",
|
|
80
|
-
"@betterstore/sdk": "0.6.
|
|
80
|
+
"@betterstore/sdk": "0.6.12"
|
|
81
81
|
},
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|