@propeller-commerce/propeller-v2-react-ui 0.15.3 → 0.15.5
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 +35 -0
- package/dist/index.cjs +22 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +22 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -4961,12 +4961,13 @@ interface ItemsOverviewProps {
|
|
|
4961
4961
|
/** Labels for the component */ labels?: Record<string, string>;
|
|
4962
4962
|
/** Currency symbol used by the default formatter. Default: `'€'`. */ currency?: string;
|
|
4963
4963
|
/** Active language for localized surcharge names. */ language?: string;
|
|
4964
|
+
/** Include tax in the line prices. Resolved from `<PropellerProvider>` when omitted; defaults to `false`. */ includeTax?: boolean;
|
|
4964
4965
|
}
|
|
4965
4966
|
/**
|
|
4966
4967
|
* Renders a compact read-only list of cart line items, including bundles and
|
|
4967
4968
|
* configurable child options, with optional image, SKU, availability and price.
|
|
4968
4969
|
*/
|
|
4969
|
-
declare function ItemsOverview(
|
|
4970
|
+
declare function ItemsOverview(rawProps: ItemsOverviewProps): React$1.JSX.Element;
|
|
4970
4971
|
|
|
4971
4972
|
/**
|
|
4972
4973
|
* @rsc-blocked — Client-only component: interactive state (useState/useReducer).
|
package/dist/index.d.ts
CHANGED
|
@@ -4961,12 +4961,13 @@ interface ItemsOverviewProps {
|
|
|
4961
4961
|
/** Labels for the component */ labels?: Record<string, string>;
|
|
4962
4962
|
/** Currency symbol used by the default formatter. Default: `'€'`. */ currency?: string;
|
|
4963
4963
|
/** Active language for localized surcharge names. */ language?: string;
|
|
4964
|
+
/** Include tax in the line prices. Resolved from `<PropellerProvider>` when omitted; defaults to `false`. */ includeTax?: boolean;
|
|
4964
4965
|
}
|
|
4965
4966
|
/**
|
|
4966
4967
|
* Renders a compact read-only list of cart line items, including bundles and
|
|
4967
4968
|
* configurable child options, with optional image, SKU, availability and price.
|
|
4968
4969
|
*/
|
|
4969
|
-
declare function ItemsOverview(
|
|
4970
|
+
declare function ItemsOverview(rawProps: ItemsOverviewProps): React$1.JSX.Element;
|
|
4970
4971
|
|
|
4971
4972
|
/**
|
|
4972
4973
|
* @rsc-blocked — Client-only component: interactive state (useState/useReducer).
|
package/dist/index.js
CHANGED
|
@@ -1572,15 +1572,15 @@ function buildCategoriesQuery(depth) {
|
|
|
1572
1572
|
categories {
|
|
1573
1573
|
categoryId
|
|
1574
1574
|
hidden
|
|
1575
|
-
names
|
|
1576
|
-
slugs
|
|
1575
|
+
names { value language }
|
|
1576
|
+
slugs { value language }
|
|
1577
1577
|
${buildCategoriesQuery(depth - 1)}
|
|
1578
1578
|
}
|
|
1579
1579
|
`;
|
|
1580
1580
|
}
|
|
1581
1581
|
function mapCategory(raw, language) {
|
|
1582
1582
|
const nameEntry = raw.names?.find((n) => n.language === language) ?? raw.names?.[0];
|
|
1583
|
-
const slugEntry = raw.slugs?.[0];
|
|
1583
|
+
const slugEntry = raw.slugs?.find((s) => s.language === language) ?? raw.slugs?.[0];
|
|
1584
1584
|
return {
|
|
1585
1585
|
categoryId: raw.categoryId,
|
|
1586
1586
|
name: nameEntry?.value ?? "",
|
|
@@ -1656,17 +1656,17 @@ function useMenu(options) {
|
|
|
1656
1656
|
inflightFetches.set(key, promise);
|
|
1657
1657
|
try {
|
|
1658
1658
|
const gql = `
|
|
1659
|
-
query Menu($categoryId: Float
|
|
1659
|
+
query Menu($categoryId: Float) {
|
|
1660
1660
|
category(categoryId: $categoryId) {
|
|
1661
1661
|
categoryId
|
|
1662
1662
|
hidden
|
|
1663
|
-
names
|
|
1664
|
-
slugs
|
|
1663
|
+
names { value language }
|
|
1664
|
+
slugs { value language }
|
|
1665
1665
|
${buildCategoriesQuery(depth)}
|
|
1666
1666
|
}
|
|
1667
1667
|
}
|
|
1668
1668
|
`;
|
|
1669
|
-
const variables = { categoryId: rootCategoryId
|
|
1669
|
+
const variables = { categoryId: rootCategoryId };
|
|
1670
1670
|
const data = await graphqlClient.query(gql, variables);
|
|
1671
1671
|
const root = data?.category ?? null;
|
|
1672
1672
|
const items = root ? (root.categories ?? []).filter((cat) => !isHidden(cat)).map((cat) => mapCategory(cat, language)) : [];
|
|
@@ -12839,7 +12839,9 @@ function getBundleNonLeaders(item) {
|
|
|
12839
12839
|
if (!items) return [];
|
|
12840
12840
|
return items.filter((bi) => bi.isLeader !== YesNo.Y);
|
|
12841
12841
|
}
|
|
12842
|
-
function ItemsOverview(
|
|
12842
|
+
function ItemsOverview(rawProps) {
|
|
12843
|
+
const props = useInfraProps(rawProps);
|
|
12844
|
+
const useTax = !!props.includeTax;
|
|
12843
12845
|
const containerClass = props.itemsOverviewContainerClass || "cart-items-overview";
|
|
12844
12846
|
const itemNameClickable = props.itemNameClickable !== void 0 ? props.itemNameClickable : true;
|
|
12845
12847
|
const showAvailability = props.showAvailability !== void 0 ? props.showAvailability : true;
|
|
@@ -12855,6 +12857,13 @@ function ItemsOverview(props) {
|
|
|
12855
12857
|
}
|
|
12856
12858
|
return formatPrice(price || 0, { symbol: currencySymbol });
|
|
12857
12859
|
}
|
|
12860
|
+
function lineTotal(item) {
|
|
12861
|
+
return (useTax ? item.totalSumNet : item.totalSum) || 0;
|
|
12862
|
+
}
|
|
12863
|
+
function bundlePrice(price) {
|
|
12864
|
+
if (!price) return void 0;
|
|
12865
|
+
return useTax ? price.net : price.gross;
|
|
12866
|
+
}
|
|
12858
12867
|
function getItemSurcharges(item) {
|
|
12859
12868
|
const list = (item.surcharges ?? []).filter(
|
|
12860
12869
|
(s) => s.enabled !== false
|
|
@@ -12917,12 +12926,12 @@ function ItemsOverview(props) {
|
|
|
12917
12926
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
12918
12927
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-between items-start gap-2", children: [
|
|
12919
12928
|
/* @__PURE__ */ jsx("span", { className: "propeller-items-overview__item-title text-sm font-medium leading-tight text-foreground line-clamp-2", children: item.bundle?.name || "Bundle" }),
|
|
12920
|
-
showPrice && money(item.bundle?.price
|
|
12929
|
+
showPrice && money(bundlePrice(item.bundle?.price)) ? /* @__PURE__ */ jsx("span", { className: "propeller-items-overview__item-price font-semibold text-sm text-foreground whitespace-nowrap", children: money(bundlePrice(item.bundle?.price)) }) : null
|
|
12921
12930
|
] }),
|
|
12922
12931
|
/* @__PURE__ */ jsxs("div", { className: "propeller-items-overview__item-bundle mt-1.5 space-y-1 border-l-2 border-secondary/10 pl-2", children: [
|
|
12923
12932
|
leader ? /* @__PURE__ */ jsxs("div", { className: "propeller-items-overview__item-bundle-leader flex justify-between items-center text-xs", children: [
|
|
12924
12933
|
/* @__PURE__ */ jsx("span", { className: "font-medium text-foreground", children: leader.product.names?.[0]?.value || "Product" }),
|
|
12925
|
-
money(leader.price
|
|
12934
|
+
money(bundlePrice(leader.price)) ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground whitespace-nowrap ml-2", children: money(bundlePrice(leader.price)) }) : null
|
|
12926
12935
|
] }) : null,
|
|
12927
12936
|
getBundleNonLeaders(item).map((bundleItem, idx) => /* @__PURE__ */ jsxs(
|
|
12928
12937
|
"div",
|
|
@@ -12930,7 +12939,7 @@ function ItemsOverview(props) {
|
|
|
12930
12939
|
className: "propeller-items-overview__item-bundle-item flex justify-between items-center text-xs text-muted-foreground",
|
|
12931
12940
|
children: [
|
|
12932
12941
|
/* @__PURE__ */ jsx("span", { className: "line-clamp-1", children: bundleItem.product?.names?.[0]?.value || "Product" }),
|
|
12933
|
-
money(bundleItem.price
|
|
12942
|
+
money(bundlePrice(bundleItem.price)) ? /* @__PURE__ */ jsx("span", { className: "text-foreground-subtle whitespace-nowrap ml-2", children: money(bundlePrice(bundleItem.price)) }) : null
|
|
12934
12943
|
]
|
|
12935
12944
|
},
|
|
12936
12945
|
idx
|
|
@@ -12953,7 +12962,7 @@ function ItemsOverview(props) {
|
|
|
12953
12962
|
children: getItemName(item)
|
|
12954
12963
|
}
|
|
12955
12964
|
) : /* @__PURE__ */ jsx("p", { className: "propeller-items-overview__item-title font-medium text-sm leading-tight line-clamp-2", children: getItemName(item) }),
|
|
12956
|
-
showPrice ? /* @__PURE__ */ jsx("span", { className: "propeller-items-overview__item-price font-semibold text-sm text-foreground whitespace-nowrap", children: formatItemPrice((item
|
|
12965
|
+
showPrice ? /* @__PURE__ */ jsx("span", { className: "propeller-items-overview__item-price font-semibold text-sm text-foreground whitespace-nowrap", children: formatItemPrice(lineTotal(item)) }) : null
|
|
12957
12966
|
] }),
|
|
12958
12967
|
showSku && itemSku ? /* @__PURE__ */ jsxs("p", { className: "propeller-items-overview__item-sku text-xs text-muted-foreground mt-0.5", children: [
|
|
12959
12968
|
"SKU: ",
|
|
@@ -12969,7 +12978,7 @@ function ItemsOverview(props) {
|
|
|
12969
12978
|
className: "propeller-items-overview__item-option flex justify-between items-center text-xs text-muted-foreground",
|
|
12970
12979
|
children: [
|
|
12971
12980
|
/* @__PURE__ */ jsx("span", { className: "line-clamp-1", children: child.product?.names?.[0]?.value || "Option" }),
|
|
12972
|
-
/* @__PURE__ */ jsx("span", { className: "text-foreground-subtle whitespace-nowrap ml-2", children: formatItemPrice(child
|
|
12981
|
+
/* @__PURE__ */ jsx("span", { className: "text-foreground-subtle whitespace-nowrap ml-2", children: formatItemPrice(lineTotal(child)) })
|
|
12973
12982
|
]
|
|
12974
12983
|
},
|
|
12975
12984
|
idx
|