@propeller-commerce/propeller-v2-react-ui 0.15.10 → 0.15.11
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 +21 -0
- package/dist/index.cjs +28 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6407,6 +6407,12 @@ function CartBonusItems(rawProps) {
|
|
|
6407
6407
|
] });
|
|
6408
6408
|
}
|
|
6409
6409
|
var CartBonusItems_default = CartBonusItems;
|
|
6410
|
+
|
|
6411
|
+
// src/composables/shared/utils/preselect.ts
|
|
6412
|
+
function pickPreselected(items, stored, keyOf) {
|
|
6413
|
+
const list = items || [];
|
|
6414
|
+
return (stored ? list.find((item) => keyOf(item) === stored) : void 0) || list[0];
|
|
6415
|
+
}
|
|
6410
6416
|
function CartCarriers(props) {
|
|
6411
6417
|
const [selectedName, setSelectedName] = useState("");
|
|
6412
6418
|
const containerClass = props.carriersContainerClass || "cart-carriers";
|
|
@@ -6420,16 +6426,16 @@ function CartCarriers(props) {
|
|
|
6420
6426
|
setSelectedName(carrier.name);
|
|
6421
6427
|
if (props.onCarrierSelect) props.onCarrierSelect(carrier);
|
|
6422
6428
|
}
|
|
6429
|
+
const preselected = pickPreselected(
|
|
6430
|
+
carriers,
|
|
6431
|
+
props.cart?.postageData?.carrier,
|
|
6432
|
+
(c) => c.name
|
|
6433
|
+
);
|
|
6434
|
+
const activeName = selectedName || preselected?.name || "";
|
|
6423
6435
|
useEffect(() => {
|
|
6424
|
-
if (
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
if (props.onCarrierSelect) {
|
|
6428
|
-
const match = carriers.find((c) => c.name === name);
|
|
6429
|
-
if (match) props.onCarrierSelect(match);
|
|
6430
|
-
}
|
|
6431
|
-
}
|
|
6432
|
-
}, [props.cart, selectedName, props.onCarrierSelect, carriers, props]);
|
|
6436
|
+
if (selectedName || !preselected) return;
|
|
6437
|
+
if (props.onCarrierSelect) props.onCarrierSelect(preselected);
|
|
6438
|
+
}, [preselected?.name]);
|
|
6433
6439
|
return /* @__PURE__ */ jsxs("div", { className: `propeller-cart-carriers ${containerClass}`, children: [
|
|
6434
6440
|
carriers.length > 0 ? /* @__PURE__ */ jsx("div", { className: "propeller-cart-carriers__grid grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3", children: carriers.map((carrier, index) => {
|
|
6435
6441
|
const logoUrl = showLogo ? carrier.logo || "" : "";
|
|
@@ -6437,8 +6443,8 @@ function CartCarriers(props) {
|
|
|
6437
6443
|
"div",
|
|
6438
6444
|
{
|
|
6439
6445
|
onClick: () => handleSelect(carrier),
|
|
6440
|
-
"data-selected":
|
|
6441
|
-
className: `propeller-cart-carriers__carrier relative cursor-pointer border rounded-container p-3 flex flex-col items-center justify-center gap-2 text-center aspect-square transition-all ${
|
|
6446
|
+
"data-selected": activeName === carrier.name ? "true" : "false",
|
|
6447
|
+
className: `propeller-cart-carriers__carrier relative cursor-pointer border rounded-container p-3 flex flex-col items-center justify-center gap-2 text-center aspect-square transition-all ${activeName === carrier.name ? "border-secondary bg-secondary/5 shadow-sm" : "border-border hover:border-secondary/30"}`,
|
|
6442
6448
|
children: [
|
|
6443
6449
|
props.showPrice !== false ? /* @__PURE__ */ jsx("span", { className: "propeller-cart-carriers__carrier-price absolute top-2 right-2 text-xs bg-surface-hover text-muted-foreground px-2 py-0.5 rounded-full", children: formatCarrierPrice(carrier.price) }) : null,
|
|
6444
6450
|
logoUrl ? /* @__PURE__ */ jsx("span", { className: "propeller-cart-carriers__carrier-logo-wrap flex items-center justify-center h-10 w-full", children: /* @__PURE__ */ jsx("img", { className: "propeller-cart-carriers__carrier-logo max-h-10 max-w-[80%] w-auto object-contain", src: logoUrl, alt: carrier.name }) }) : null,
|
|
@@ -7742,16 +7748,16 @@ function CartPaymethods(rawProps) {
|
|
|
7742
7748
|
setSelectedCode(method.code);
|
|
7743
7749
|
if (props.onPaymethodSelect) props.onPaymethodSelect(method);
|
|
7744
7750
|
}
|
|
7751
|
+
const preselected = pickPreselected(
|
|
7752
|
+
payMethods,
|
|
7753
|
+
props.cart?.paymentData?.method,
|
|
7754
|
+
(m) => m.code
|
|
7755
|
+
);
|
|
7756
|
+
const activeCode = selectedCode || preselected?.code || "";
|
|
7745
7757
|
useEffect(() => {
|
|
7746
|
-
if (
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
if (props.onPaymethodSelect) {
|
|
7750
|
-
const match = payMethods.find((m) => m.code === code);
|
|
7751
|
-
if (match) props.onPaymethodSelect(match);
|
|
7752
|
-
}
|
|
7753
|
-
}
|
|
7754
|
-
}, [props.cart, selectedCode, props.onPaymethodSelect, payMethods, props]);
|
|
7758
|
+
if (selectedCode || !preselected) return;
|
|
7759
|
+
if (props.onPaymethodSelect) props.onPaymethodSelect(preselected);
|
|
7760
|
+
}, [preselected?.code]);
|
|
7755
7761
|
return /* @__PURE__ */ jsxs("div", { className: `propeller-cart-paymethods ${containerClass}`, children: [
|
|
7756
7762
|
payMethods.length > 0 ? /* @__PURE__ */ jsx("div", { className: "propeller-cart-paymethods__grid grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3", children: payMethods.map((method, index) => {
|
|
7757
7763
|
const logoUrl = showLogo ? getLogoUrl(method) : "";
|
|
@@ -7759,8 +7765,8 @@ function CartPaymethods(rawProps) {
|
|
|
7759
7765
|
"div",
|
|
7760
7766
|
{
|
|
7761
7767
|
onClick: () => handleSelect(method),
|
|
7762
|
-
"data-selected":
|
|
7763
|
-
className: `propeller-cart-paymethods__method relative cursor-pointer border rounded-container p-3 flex flex-col items-center justify-center gap-2 text-center aspect-square transition-all ${
|
|
7768
|
+
"data-selected": activeCode === method.code ? "true" : "false",
|
|
7769
|
+
className: `propeller-cart-paymethods__method relative cursor-pointer border rounded-container p-3 flex flex-col items-center justify-center gap-2 text-center aspect-square transition-all ${activeCode === method.code ? "border-secondary bg-secondary/5 shadow-sm" : "border-border hover:border-secondary/30"}`,
|
|
7764
7770
|
children: [
|
|
7765
7771
|
method.price > 0 ? /* @__PURE__ */ jsx("span", { className: "propeller-cart-paymethods__method-price absolute top-2 right-2 text-xs bg-surface-hover text-muted-foreground px-2 py-0.5 rounded-full", children: formatMethodPrice(method.price) }) : null,
|
|
7766
7772
|
logoUrl ? /* @__PURE__ */ jsx("span", { className: "propeller-cart-paymethods__method-logo-wrap flex items-center justify-center h-10 w-full", children: /* @__PURE__ */ jsx(
|