@propeller-commerce/propeller-v2-react-ui 0.15.9 → 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 +38 -0
- package/dist/index.cjs +37 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +37 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -3335,6 +3335,8 @@ interface CartIconAndSidebarProps {
|
|
|
3335
3335
|
* localized page. Keys match CartItem's label map.
|
|
3336
3336
|
*/
|
|
3337
3337
|
cartItemLabels?: Record<string, string>;
|
|
3338
|
+
/** Labels for the bonus-items block. Keys: `title`, `sku`. */
|
|
3339
|
+
cartBonusItemsLabels?: Record<string, string>;
|
|
3338
3340
|
/** Logged-in user — used to determine purchaser role and authorization limit */
|
|
3339
3341
|
user?: Contact | Customer;
|
|
3340
3342
|
/** Configuration object passed to the component */
|
package/dist/index.d.ts
CHANGED
|
@@ -3335,6 +3335,8 @@ interface CartIconAndSidebarProps {
|
|
|
3335
3335
|
* localized page. Keys match CartItem's label map.
|
|
3336
3336
|
*/
|
|
3337
3337
|
cartItemLabels?: Record<string, string>;
|
|
3338
|
+
/** Labels for the bonus-items block. Keys: `title`, `sku`. */
|
|
3339
|
+
cartBonusItemsLabels?: Record<string, string>;
|
|
3338
3340
|
/** Logged-in user — used to determine purchaser role and authorization limit */
|
|
3339
3341
|
user?: Contact | Customer;
|
|
3340
3342
|
/** Configuration object passed to the component */
|
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,
|
|
@@ -7477,7 +7483,15 @@ function CartIconAndSidebar(rawProps) {
|
|
|
7477
7483
|
},
|
|
7478
7484
|
item.itemId
|
|
7479
7485
|
)) }),
|
|
7480
|
-
/* @__PURE__ */ jsx(
|
|
7486
|
+
/* @__PURE__ */ jsx(
|
|
7487
|
+
CartBonusItemsImpl,
|
|
7488
|
+
{
|
|
7489
|
+
cart: props.cart,
|
|
7490
|
+
includeTax: useTax,
|
|
7491
|
+
className: "mt-4",
|
|
7492
|
+
labels: props.cartBonusItemsLabels
|
|
7493
|
+
}
|
|
7494
|
+
)
|
|
7481
7495
|
] }),
|
|
7482
7496
|
" ",
|
|
7483
7497
|
items.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "propeller-cart-icon__sidebar-footer px-5 py-4 border-t border-border space-y-3 bg-surface-hover", children: [
|
|
@@ -7734,16 +7748,16 @@ function CartPaymethods(rawProps) {
|
|
|
7734
7748
|
setSelectedCode(method.code);
|
|
7735
7749
|
if (props.onPaymethodSelect) props.onPaymethodSelect(method);
|
|
7736
7750
|
}
|
|
7751
|
+
const preselected = pickPreselected(
|
|
7752
|
+
payMethods,
|
|
7753
|
+
props.cart?.paymentData?.method,
|
|
7754
|
+
(m) => m.code
|
|
7755
|
+
);
|
|
7756
|
+
const activeCode = selectedCode || preselected?.code || "";
|
|
7737
7757
|
useEffect(() => {
|
|
7738
|
-
if (
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
if (props.onPaymethodSelect) {
|
|
7742
|
-
const match = payMethods.find((m) => m.code === code);
|
|
7743
|
-
if (match) props.onPaymethodSelect(match);
|
|
7744
|
-
}
|
|
7745
|
-
}
|
|
7746
|
-
}, [props.cart, selectedCode, props.onPaymethodSelect, payMethods, props]);
|
|
7758
|
+
if (selectedCode || !preselected) return;
|
|
7759
|
+
if (props.onPaymethodSelect) props.onPaymethodSelect(preselected);
|
|
7760
|
+
}, [preselected?.code]);
|
|
7747
7761
|
return /* @__PURE__ */ jsxs("div", { className: `propeller-cart-paymethods ${containerClass}`, children: [
|
|
7748
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) => {
|
|
7749
7763
|
const logoUrl = showLogo ? getLogoUrl(method) : "";
|
|
@@ -7751,8 +7765,8 @@ function CartPaymethods(rawProps) {
|
|
|
7751
7765
|
"div",
|
|
7752
7766
|
{
|
|
7753
7767
|
onClick: () => handleSelect(method),
|
|
7754
|
-
"data-selected":
|
|
7755
|
-
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"}`,
|
|
7756
7770
|
children: [
|
|
7757
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,
|
|
7758
7772
|
logoUrl ? /* @__PURE__ */ jsx("span", { className: "propeller-cart-paymethods__method-logo-wrap flex items-center justify-center h-10 w-full", children: /* @__PURE__ */ jsx(
|