@betterstore/react 0.2.45 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/components/checkout-embed/steps/summary/index.d.ts +2 -2
- package/dist/index.cjs.js +23 -16
- package/dist/index.mjs +23 -16
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LineItem } from "@betterstore/sdk";
|
|
2
2
|
import React from "react";
|
|
3
|
-
export default function CheckoutSummary({ lineItems, shipping, tax, currency,
|
|
3
|
+
export default function CheckoutSummary({ lineItems, shipping, tax, currency, onCancel, exchangeRate, }: {
|
|
4
4
|
lineItems: LineItem[];
|
|
5
5
|
shipping?: number;
|
|
6
6
|
tax?: number;
|
|
7
7
|
currency: string;
|
|
8
8
|
exchangeRate: number;
|
|
9
|
-
|
|
9
|
+
onCancel: () => void;
|
|
10
10
|
}): React.JSX.Element;
|
package/dist/index.cjs.js
CHANGED
|
@@ -3240,8 +3240,8 @@ const CheckoutEmbed$2 = {
|
|
|
3240
3240
|
zipCodePlaceholder: "12345"
|
|
3241
3241
|
},
|
|
3242
3242
|
button: "Uložit a pokračovat",
|
|
3243
|
-
email: "
|
|
3244
|
-
emailPlaceholder: "Zadejte svůj
|
|
3243
|
+
email: "Email",
|
|
3244
|
+
emailPlaceholder: "Zadejte svůj email",
|
|
3245
3245
|
firstName: "Křestní jméno",
|
|
3246
3246
|
firstNamePlaceholder: "Zadejte své křestní jméno",
|
|
3247
3247
|
lastName: "Příjmení",
|
|
@@ -3253,11 +3253,11 @@ const CheckoutEmbed$2 = {
|
|
|
3253
3253
|
Summary: {
|
|
3254
3254
|
calculatedAtNextStep: "Vypočítáno v dalším kroku",
|
|
3255
3255
|
edit: "Upravit",
|
|
3256
|
-
shipping: "
|
|
3257
|
-
subtotal: "
|
|
3256
|
+
shipping: "Doprava",
|
|
3257
|
+
subtotal: "Mezisoučet",
|
|
3258
3258
|
tax: "Daň",
|
|
3259
3259
|
title: "Shrnutí",
|
|
3260
|
-
total: "
|
|
3260
|
+
total: "Celkem"
|
|
3261
3261
|
},
|
|
3262
3262
|
loading: "Načítání ...",
|
|
3263
3263
|
Payment: {
|
|
@@ -5480,7 +5480,7 @@ class MotionValue {
|
|
|
5480
5480
|
* This will be replaced by the build step with the latest version number.
|
|
5481
5481
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
5482
5482
|
*/
|
|
5483
|
-
this.version = "12.9.
|
|
5483
|
+
this.version = "12.9.1";
|
|
5484
5484
|
/**
|
|
5485
5485
|
* Tracks whether this value can output a velocity. Currently this is only true
|
|
5486
5486
|
* if the value is numerical, but we might be able to widen the scope here and support
|
|
@@ -7296,13 +7296,13 @@ class JSAnimation extends WithPromise {
|
|
|
7296
7296
|
}
|
|
7297
7297
|
onPlay && onPlay();
|
|
7298
7298
|
const now = this.driver.now();
|
|
7299
|
-
if (this.
|
|
7300
|
-
this.startTime = now - this.holdTime;
|
|
7301
|
-
}
|
|
7302
|
-
else if (this.state === "finished") {
|
|
7299
|
+
if (this.state === "finished") {
|
|
7303
7300
|
this.updateFinished();
|
|
7304
7301
|
this.startTime = now;
|
|
7305
7302
|
}
|
|
7303
|
+
else if (this.holdTime !== null) {
|
|
7304
|
+
this.startTime = now - this.holdTime;
|
|
7305
|
+
}
|
|
7306
7306
|
else if (!this.startTime) {
|
|
7307
7307
|
this.startTime = startTime ?? now;
|
|
7308
7308
|
}
|
|
@@ -12712,7 +12712,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
12712
12712
|
* and warn against mismatches.
|
|
12713
12713
|
*/
|
|
12714
12714
|
if (process.env.NODE_ENV === "development") {
|
|
12715
|
-
warnOnce(nextValue.version === "12.9.
|
|
12715
|
+
warnOnce(nextValue.version === "12.9.1", `Attempting to mix Motion versions ${nextValue.version} with 12.9.1 may not work as expected.`);
|
|
12716
12716
|
}
|
|
12717
12717
|
}
|
|
12718
12718
|
else if (isMotionValue(prevValue)) {
|
|
@@ -34160,6 +34160,7 @@ function ShippingMethodForm({ shippingRates, initialData, onSubmit, onBack, cont
|
|
|
34160
34160
|
provider: "",
|
|
34161
34161
|
price: 0,
|
|
34162
34162
|
pickupPointId: "",
|
|
34163
|
+
pickupPointDisplayName: "",
|
|
34163
34164
|
},
|
|
34164
34165
|
});
|
|
34165
34166
|
const currentRateId = form.watch("rateId");
|
|
@@ -34401,6 +34402,7 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
|
|
|
34401
34402
|
shipmentData: {
|
|
34402
34403
|
provider: data.provider,
|
|
34403
34404
|
pickupPointId: data.pickupPointId,
|
|
34405
|
+
name: data.pickupPointDisplayName,
|
|
34404
34406
|
},
|
|
34405
34407
|
});
|
|
34406
34408
|
const { paymentSecret, publicKey } = yield storeClient.generateCheckoutsPaymentSecret(clientSecret, checkoutId);
|
|
@@ -34461,7 +34463,7 @@ function InputGroupLoading({ className }) {
|
|
|
34461
34463
|
React.createElement(Skeleton, { className: "w-full h-9" })));
|
|
34462
34464
|
}
|
|
34463
34465
|
|
|
34464
|
-
function CheckoutSummary({ lineItems, shipping, tax, currency,
|
|
34466
|
+
function CheckoutSummary({ lineItems, shipping, tax, currency, onCancel, exchangeRate, }) {
|
|
34465
34467
|
var _a;
|
|
34466
34468
|
const { formData } = useFormStore();
|
|
34467
34469
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
@@ -34488,8 +34490,7 @@ function CheckoutSummary({ lineItems, shipping, tax, currency, cancelUrl, exchan
|
|
|
34488
34490
|
"rotate-180": isOpen,
|
|
34489
34491
|
}) })),
|
|
34490
34492
|
React.createElement("p", { className: "font-bold text-lg tracking-tight md:hidden" }, storeHelpers.formatPrice(total, currency, exchangeRate)),
|
|
34491
|
-
React.createElement(Button, { className: "max-sm:hidden", variant: "link", size: "link",
|
|
34492
|
-
React.createElement("a", { href: cancelUrl }, t("CheckoutEmbed.Summary.edit")))),
|
|
34493
|
+
React.createElement(Button, { className: "max-sm:hidden", variant: "link", size: "link", onClick: onCancel }, t("CheckoutEmbed.Summary.edit"))),
|
|
34493
34494
|
React.createElement("hr", null),
|
|
34494
34495
|
React.createElement("div", { className: clsx("gap-3 order-4 md:order-none", {
|
|
34495
34496
|
"hidden md:grid": !isOpen,
|
|
@@ -34579,6 +34580,7 @@ function CheckoutEmbed({ checkoutId, config }) {
|
|
|
34579
34580
|
const { cancelUrl, successUrl, appearance, locale, clientSecret, clientProxy, } = config;
|
|
34580
34581
|
const storeClient = sdk.createStoreClient({ proxy: clientProxy });
|
|
34581
34582
|
React.useMemo(() => createI18nInstance(locale), []);
|
|
34583
|
+
const { formData, setFormData, step, setStep } = useFormStore();
|
|
34582
34584
|
const [checkout, setCheckout] = React.useState(null);
|
|
34583
34585
|
const [loading, setLoading] = React.useState(true);
|
|
34584
34586
|
React.useEffect(() => {
|
|
@@ -34607,15 +34609,20 @@ function CheckoutEmbed({ checkoutId, config }) {
|
|
|
34607
34609
|
};
|
|
34608
34610
|
}, [checkoutId]); // Only re-run if checkoutId changes
|
|
34609
34611
|
const onSuccess = () => {
|
|
34612
|
+
setStep("customer");
|
|
34613
|
+
setFormData({ customer: formData.customer });
|
|
34610
34614
|
if (successUrl) {
|
|
34611
34615
|
window.location.href = successUrl;
|
|
34612
34616
|
}
|
|
34613
34617
|
};
|
|
34614
|
-
const
|
|
34618
|
+
const onCancel = () => {
|
|
34619
|
+
setStep("customer");
|
|
34620
|
+
setFormData({ customer: formData.customer });
|
|
34615
34621
|
if (cancelUrl) {
|
|
34616
34622
|
window.location.href = cancelUrl;
|
|
34617
34623
|
}
|
|
34618
34624
|
};
|
|
34625
|
+
const onError = () => { };
|
|
34619
34626
|
if (!checkout && !loading) {
|
|
34620
34627
|
throw new Error("Checkout not found");
|
|
34621
34628
|
}
|
|
@@ -34627,7 +34634,7 @@ function CheckoutEmbed({ checkoutId, config }) {
|
|
|
34627
34634
|
return (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 " },
|
|
34628
34635
|
React.createElement(Appearance, { appearance: appearance }),
|
|
34629
34636
|
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 }))),
|
|
34630
|
-
React.createElement("div", { className: "md:col-span-3 px-4 md:px-8 order-first md:order-last" }, loading ? (React.createElement(CheckoutSummaryLoading, null)) : (React.createElement(CheckoutSummary, { currency: (_c = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _c !== void 0 ? _c : "", lineItems: (_d = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) !== null && _d !== void 0 ? _d : [], shipping: checkout === null || checkout === void 0 ? void 0 : checkout.shipping, tax: checkout === null || checkout === void 0 ? void 0 : checkout.tax,
|
|
34637
|
+
React.createElement("div", { className: "md:col-span-3 px-4 md:px-8 order-first md:order-last" }, loading ? (React.createElement(CheckoutSummaryLoading, null)) : (React.createElement(CheckoutSummary, { currency: (_c = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _c !== void 0 ? _c : "", lineItems: (_d = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) !== null && _d !== void 0 ? _d : [], shipping: checkout === null || checkout === void 0 ? void 0 : checkout.shipping, tax: checkout === null || checkout === void 0 ? void 0 : checkout.tax, onCancel: onCancel, exchangeRate: (_e = checkout === null || checkout === void 0 ? void 0 : checkout.exchangeRate) !== null && _e !== void 0 ? _e : 1 })))));
|
|
34631
34638
|
}
|
|
34632
34639
|
var index = React.memo(CheckoutEmbed);
|
|
34633
34640
|
|
package/dist/index.mjs
CHANGED
|
@@ -3217,8 +3217,8 @@ const CheckoutEmbed$2 = {
|
|
|
3217
3217
|
zipCodePlaceholder: "12345"
|
|
3218
3218
|
},
|
|
3219
3219
|
button: "Uložit a pokračovat",
|
|
3220
|
-
email: "
|
|
3221
|
-
emailPlaceholder: "Zadejte svůj
|
|
3220
|
+
email: "Email",
|
|
3221
|
+
emailPlaceholder: "Zadejte svůj email",
|
|
3222
3222
|
firstName: "Křestní jméno",
|
|
3223
3223
|
firstNamePlaceholder: "Zadejte své křestní jméno",
|
|
3224
3224
|
lastName: "Příjmení",
|
|
@@ -3230,11 +3230,11 @@ const CheckoutEmbed$2 = {
|
|
|
3230
3230
|
Summary: {
|
|
3231
3231
|
calculatedAtNextStep: "Vypočítáno v dalším kroku",
|
|
3232
3232
|
edit: "Upravit",
|
|
3233
|
-
shipping: "
|
|
3234
|
-
subtotal: "
|
|
3233
|
+
shipping: "Doprava",
|
|
3234
|
+
subtotal: "Mezisoučet",
|
|
3235
3235
|
tax: "Daň",
|
|
3236
3236
|
title: "Shrnutí",
|
|
3237
|
-
total: "
|
|
3237
|
+
total: "Celkem"
|
|
3238
3238
|
},
|
|
3239
3239
|
loading: "Načítání ...",
|
|
3240
3240
|
Payment: {
|
|
@@ -5457,7 +5457,7 @@ class MotionValue {
|
|
|
5457
5457
|
* This will be replaced by the build step with the latest version number.
|
|
5458
5458
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
5459
5459
|
*/
|
|
5460
|
-
this.version = "12.9.
|
|
5460
|
+
this.version = "12.9.1";
|
|
5461
5461
|
/**
|
|
5462
5462
|
* Tracks whether this value can output a velocity. Currently this is only true
|
|
5463
5463
|
* if the value is numerical, but we might be able to widen the scope here and support
|
|
@@ -7273,13 +7273,13 @@ class JSAnimation extends WithPromise {
|
|
|
7273
7273
|
}
|
|
7274
7274
|
onPlay && onPlay();
|
|
7275
7275
|
const now = this.driver.now();
|
|
7276
|
-
if (this.
|
|
7277
|
-
this.startTime = now - this.holdTime;
|
|
7278
|
-
}
|
|
7279
|
-
else if (this.state === "finished") {
|
|
7276
|
+
if (this.state === "finished") {
|
|
7280
7277
|
this.updateFinished();
|
|
7281
7278
|
this.startTime = now;
|
|
7282
7279
|
}
|
|
7280
|
+
else if (this.holdTime !== null) {
|
|
7281
|
+
this.startTime = now - this.holdTime;
|
|
7282
|
+
}
|
|
7283
7283
|
else if (!this.startTime) {
|
|
7284
7284
|
this.startTime = startTime ?? now;
|
|
7285
7285
|
}
|
|
@@ -12689,7 +12689,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
12689
12689
|
* and warn against mismatches.
|
|
12690
12690
|
*/
|
|
12691
12691
|
if (process.env.NODE_ENV === "development") {
|
|
12692
|
-
warnOnce(nextValue.version === "12.9.
|
|
12692
|
+
warnOnce(nextValue.version === "12.9.1", `Attempting to mix Motion versions ${nextValue.version} with 12.9.1 may not work as expected.`);
|
|
12693
12693
|
}
|
|
12694
12694
|
}
|
|
12695
12695
|
else if (isMotionValue(prevValue)) {
|
|
@@ -34137,6 +34137,7 @@ function ShippingMethodForm({ shippingRates, initialData, onSubmit, onBack, cont
|
|
|
34137
34137
|
provider: "",
|
|
34138
34138
|
price: 0,
|
|
34139
34139
|
pickupPointId: "",
|
|
34140
|
+
pickupPointDisplayName: "",
|
|
34140
34141
|
},
|
|
34141
34142
|
});
|
|
34142
34143
|
const currentRateId = form.watch("rateId");
|
|
@@ -34378,6 +34379,7 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
|
|
|
34378
34379
|
shipmentData: {
|
|
34379
34380
|
provider: data.provider,
|
|
34380
34381
|
pickupPointId: data.pickupPointId,
|
|
34382
|
+
name: data.pickupPointDisplayName,
|
|
34381
34383
|
},
|
|
34382
34384
|
});
|
|
34383
34385
|
const { paymentSecret, publicKey } = yield storeClient.generateCheckoutsPaymentSecret(clientSecret, checkoutId);
|
|
@@ -34438,7 +34440,7 @@ function InputGroupLoading({ className }) {
|
|
|
34438
34440
|
React__default.createElement(Skeleton, { className: "w-full h-9" })));
|
|
34439
34441
|
}
|
|
34440
34442
|
|
|
34441
|
-
function CheckoutSummary({ lineItems, shipping, tax, currency,
|
|
34443
|
+
function CheckoutSummary({ lineItems, shipping, tax, currency, onCancel, exchangeRate, }) {
|
|
34442
34444
|
var _a;
|
|
34443
34445
|
const { formData } = useFormStore();
|
|
34444
34446
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -34465,8 +34467,7 @@ function CheckoutSummary({ lineItems, shipping, tax, currency, cancelUrl, exchan
|
|
|
34465
34467
|
"rotate-180": isOpen,
|
|
34466
34468
|
}) })),
|
|
34467
34469
|
React__default.createElement("p", { className: "font-bold text-lg tracking-tight md:hidden" }, storeHelpers.formatPrice(total, currency, exchangeRate)),
|
|
34468
|
-
React__default.createElement(Button, { className: "max-sm:hidden", variant: "link", size: "link",
|
|
34469
|
-
React__default.createElement("a", { href: cancelUrl }, t("CheckoutEmbed.Summary.edit")))),
|
|
34470
|
+
React__default.createElement(Button, { className: "max-sm:hidden", variant: "link", size: "link", onClick: onCancel }, t("CheckoutEmbed.Summary.edit"))),
|
|
34470
34471
|
React__default.createElement("hr", null),
|
|
34471
34472
|
React__default.createElement("div", { className: clsx("gap-3 order-4 md:order-none", {
|
|
34472
34473
|
"hidden md:grid": !isOpen,
|
|
@@ -34556,6 +34557,7 @@ function CheckoutEmbed({ checkoutId, config }) {
|
|
|
34556
34557
|
const { cancelUrl, successUrl, appearance, locale, clientSecret, clientProxy, } = config;
|
|
34557
34558
|
const storeClient = createStoreClient({ proxy: clientProxy });
|
|
34558
34559
|
React__default.useMemo(() => createI18nInstance(locale), []);
|
|
34560
|
+
const { formData, setFormData, step, setStep } = useFormStore();
|
|
34559
34561
|
const [checkout, setCheckout] = useState(null);
|
|
34560
34562
|
const [loading, setLoading] = useState(true);
|
|
34561
34563
|
useEffect(() => {
|
|
@@ -34584,15 +34586,20 @@ function CheckoutEmbed({ checkoutId, config }) {
|
|
|
34584
34586
|
};
|
|
34585
34587
|
}, [checkoutId]); // Only re-run if checkoutId changes
|
|
34586
34588
|
const onSuccess = () => {
|
|
34589
|
+
setStep("customer");
|
|
34590
|
+
setFormData({ customer: formData.customer });
|
|
34587
34591
|
if (successUrl) {
|
|
34588
34592
|
window.location.href = successUrl;
|
|
34589
34593
|
}
|
|
34590
34594
|
};
|
|
34591
|
-
const
|
|
34595
|
+
const onCancel = () => {
|
|
34596
|
+
setStep("customer");
|
|
34597
|
+
setFormData({ customer: formData.customer });
|
|
34592
34598
|
if (cancelUrl) {
|
|
34593
34599
|
window.location.href = cancelUrl;
|
|
34594
34600
|
}
|
|
34595
34601
|
};
|
|
34602
|
+
const onError = () => { };
|
|
34596
34603
|
if (!checkout && !loading) {
|
|
34597
34604
|
throw new Error("Checkout not found");
|
|
34598
34605
|
}
|
|
@@ -34604,7 +34611,7 @@ function CheckoutEmbed({ checkoutId, config }) {
|
|
|
34604
34611
|
return (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 " },
|
|
34605
34612
|
React__default.createElement(Appearance, { appearance: appearance }),
|
|
34606
34613
|
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 }))),
|
|
34607
|
-
React__default.createElement("div", { className: "md:col-span-3 px-4 md:px-8 order-first md:order-last" }, loading ? (React__default.createElement(CheckoutSummaryLoading, null)) : (React__default.createElement(CheckoutSummary, { currency: (_c = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _c !== void 0 ? _c : "", lineItems: (_d = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) !== null && _d !== void 0 ? _d : [], shipping: checkout === null || checkout === void 0 ? void 0 : checkout.shipping, tax: checkout === null || checkout === void 0 ? void 0 : checkout.tax,
|
|
34614
|
+
React__default.createElement("div", { className: "md:col-span-3 px-4 md:px-8 order-first md:order-last" }, loading ? (React__default.createElement(CheckoutSummaryLoading, null)) : (React__default.createElement(CheckoutSummary, { currency: (_c = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _c !== void 0 ? _c : "", lineItems: (_d = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) !== null && _d !== void 0 ? _d : [], shipping: checkout === null || checkout === void 0 ? void 0 : checkout.shipping, tax: checkout === null || checkout === void 0 ? void 0 : checkout.tax, onCancel: onCancel, exchangeRate: (_e = checkout === null || checkout === void 0 ? void 0 : checkout.exchangeRate) !== null && _e !== void 0 ? _e : 1 })))));
|
|
34608
34615
|
}
|
|
34609
34616
|
var index = memo$1(CheckoutEmbed);
|
|
34610
34617
|
|