@propeller-commerce/propeller-v2-react-ui 0.16.0 → 0.19.0

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/pure.cjs CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var propellerV2CoreUi = require('@propeller-commerce/propeller-v2-core-ui');
4
+ var clsx = require('clsx');
5
+ var tailwindMerge = require('tailwind-merge');
4
6
  var jsxRuntime = require('react/jsx-runtime');
5
7
  var React = require('react');
6
8
  var propellerSdkV2 = require('@propeller-commerce/propeller-sdk-v2');
@@ -26,6 +28,9 @@ function _interopNamespace(e) {
26
28
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
27
29
 
28
30
  // src/components/Breadcrumbs.tsx
31
+ function cn(...inputs) {
32
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
33
+ }
29
34
  function Breadcrumbs(props) {
30
35
  const lang = props.language || "NL";
31
36
  const path = props.categoryPath || [];
@@ -58,7 +63,7 @@ function Breadcrumbs(props) {
58
63
  return index === displayItems.length - 1;
59
64
  }
60
65
  const showSeparatorBefore = (index) => props.showHome !== false || index > 0;
61
- return /* @__PURE__ */ jsxRuntime.jsx("nav", { "aria-label": propellerV2CoreUi.getLabel(props.labels, "breadcrumbAriaLabel", "Breadcrumb"), className: `propeller-breadcrumbs ${props.className || ""}`, children: /* @__PURE__ */ jsxRuntime.jsxs("ol", { className: "propeller-breadcrumbs__list flex flex-wrap items-center text-sm text-muted-foreground", children: [
66
+ return /* @__PURE__ */ jsxRuntime.jsx("nav", { "aria-label": propellerV2CoreUi.getLabel(props.labels, "breadcrumbAriaLabel", "Breadcrumb"), className: cn(`propeller-breadcrumbs ${props.className || ""}`), children: /* @__PURE__ */ jsxRuntime.jsxs("ol", { className: "propeller-breadcrumbs__list flex flex-wrap items-center text-sm text-muted-foreground", children: [
62
67
  props.showHome !== false ? /* @__PURE__ */ jsxRuntime.jsx("li", { className: "propeller-breadcrumbs__item flex items-center", "data-home": "true", children: /* @__PURE__ */ jsxRuntime.jsx(
63
68
  "a",
64
69
  {
@@ -164,7 +169,7 @@ function CategoryShortDescription(props) {
164
169
  (d) => d.language === props.language
165
170
  );
166
171
  const html = match?.value || "";
167
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: !!html ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: `propeller-category-short-description mb-6 ${props.className || ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(
172
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: !!html ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(`propeller-category-short-description mb-6 ${props.className || ""}`), children: /* @__PURE__ */ jsxRuntime.jsx(
168
173
  "div",
169
174
  {
170
175
  className: "propeller-category-short-description__content prose prose-slate max-w-none text-muted-foreground",
@@ -174,7 +179,7 @@ function CategoryShortDescription(props) {
174
179
  }
175
180
  var CategoryShortDescription_default = CategoryShortDescription;
176
181
  function GridTitle(props) {
177
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `propeller-grid-title mb-8 ${props.className || ""}`, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "propeller-grid-title__row flex items-baseline gap-3 mb-3", children: [
182
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(`propeller-grid-title mb-8 ${props.className || ""}`), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "propeller-grid-title__row flex items-baseline gap-3 mb-3", children: [
178
183
  props.headingLevel === "h2" ? /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "propeller-grid-title__heading text-3xl sm:text-4xl font-bold tracking-tight", children: props.title }) : null,
179
184
  props.headingLevel !== "h2" ? /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "propeller-grid-title__heading text-3xl sm:text-4xl font-bold tracking-tight", children: props.title }) : null
180
185
  ] }) });
@@ -222,7 +227,7 @@ function ItemStock(props) {
222
227
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: hasInventory() ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(
223
228
  "div",
224
229
  {
225
- className: `propeller-item-stock flex flex-wrap items-center gap-1.5 ${props.className || ""}`,
230
+ className: cn(`propeller-item-stock flex flex-wrap items-center gap-1.5 ${props.className || ""}`),
226
231
  "data-available": isAvailable() ? "true" : "false",
227
232
  "data-stock": getStockStatusData(),
228
233
  children: [
@@ -264,20 +269,21 @@ var ItemStock_default = React__namespace.memo(ItemStock);
264
269
  function getProductName(orderItem, language) {
265
270
  return propellerV2CoreUi.getLocalizedValue(orderItem?.product?.names, language, "") || orderItem?.name || "Unknown Product";
266
271
  }
267
- function getClusterUrl(orderItem, language) {
272
+ function getClusterUrl(orderItem, language, urls) {
268
273
  const cluster = orderItem?.product?.cluster;
269
274
  if (!cluster) return "";
270
275
  const id = cluster.clusterId;
271
276
  const slug = propellerV2CoreUi.getLocalizedValue(cluster.slugs, language, "");
272
277
  if (!id || !slug) return "";
273
- return `/cluster/${id}/${slug}`;
278
+ return urls?.getClusterUrl?.(cluster, language) || `/cluster/${id}/${slug}`;
274
279
  }
275
- function getProductUrl(orderItem, language) {
276
- const cu = getClusterUrl(orderItem, language);
280
+ function getProductUrl(orderItem, language, urls) {
281
+ const cu = getClusterUrl(orderItem, language, urls);
277
282
  if (cu) return cu;
278
- const id = orderItem?.product?.productId;
279
- const slug = propellerV2CoreUi.getLocalizedValue(orderItem?.product?.slugs, language, "");
280
- if (id && slug) return `/product/${id}/${slug}`;
283
+ const product = orderItem?.product;
284
+ const id = product?.productId;
285
+ const slug = propellerV2CoreUi.getLocalizedValue(product?.slugs, language, "");
286
+ if (id && slug) return urls?.getProductUrl?.(product, language) || `/product/${id}/${slug}`;
281
287
  return "";
282
288
  }
283
289
  function OrderItemCard(props) {
@@ -294,7 +300,7 @@ function OrderItemCard(props) {
294
300
  const productName = getProductName(item, props.language);
295
301
  const productSku = item?.product?.sku || item?.sku || "";
296
302
  const productImage = item?.product?.media?.images?.items?.[0]?.imageVariants?.[0]?.url || "";
297
- const productUrl = getProductUrl(item, props.language);
303
+ const productUrl = getProductUrl(item, props.language, props.configuration?.urls);
298
304
  const quantity = item?.quantity || 0;
299
305
  const priceTotal = item?.priceTotal || 0;
300
306
  const discount = item?.discount || 0;
@@ -307,7 +313,7 @@ function OrderItemCard(props) {
307
313
  return props.formatPrice(price);
308
314
  }
309
315
  if (!price && price !== 0) return "-";
310
- return propellerV2CoreUi.formatPrice(price, { symbol: props.currency ?? "\u20AC" });
316
+ return propellerV2CoreUi.formatPrice(price, { symbol: props.currency ?? "\u20AC", locale: propellerV2CoreUi.localeForLanguage(props.language) });
311
317
  }
312
318
  const discountDisplay = discountPercentage > 0 ? `${formatItemPrice(discount)} (${discountPercentage.toFixed(2).replace(".", ",")}%)` : formatItemPrice(discount);
313
319
  return /* @__PURE__ */ jsxRuntime.jsxs("tbody", { className: "propeller-order-item-card", children: [
@@ -448,7 +454,7 @@ function OrderSummary(props) {
448
454
  if (props.formatPrice) {
449
455
  return props.formatPrice(price);
450
456
  }
451
- return propellerV2CoreUi.formatPrice(price || 0, { symbol: props.currency ?? "\u20AC" });
457
+ return propellerV2CoreUi.formatPrice(price || 0, { symbol: props.currency ?? "\u20AC", locale: propellerV2CoreUi.localeForLanguage(props.language) });
452
458
  }
453
459
  function numericDate(dateString) {
454
460
  const d = new Date(dateString);
@@ -556,7 +562,7 @@ function OrderTotals(props) {
556
562
  const postageData = props.order?.postageData;
557
563
  function formatItemPrice(price) {
558
564
  if (props.formatPrice) return props.formatPrice(price);
559
- return propellerV2CoreUi.formatPrice(price || 0, { symbol: props.currency ?? "\u20AC" });
565
+ return propellerV2CoreUi.formatPrice(price || 0, { symbol: props.currency ?? "\u20AC", locale: propellerV2CoreUi.localeForLanguage(props.language) });
560
566
  }
561
567
  const subtotal = total?.gross || 0;
562
568
  const hasDiscount = !!total && total.discountType !== propellerSdkV2.OrderDiscountType.N && total.discountValue > 0;
@@ -684,7 +690,7 @@ function ProductBulkPrices(props) {
684
690
  function getPrice(tier) {
685
691
  const value = includeTax ? tier.net : tier.gross;
686
692
  if (value === null || value === void 0) return "";
687
- return propellerV2CoreUi.formatPrice(value, { symbol: props.currency ?? "\u20AC" });
693
+ return propellerV2CoreUi.formatPrice(value, { symbol: props.currency ?? "\u20AC", locale: propellerV2CoreUi.localeForLanguage(props.language) });
688
694
  }
689
695
  function getQuantityLabel(tier, index) {
690
696
  const discount = tier.discount;
@@ -695,13 +701,14 @@ function ProductBulkPrices(props) {
695
701
  if (nextQty) return `${qty}\u2013${nextQty - 1}`;
696
702
  return `${qty}+`;
697
703
  }
704
+ const title = props.labels?.title ?? "Volume pricing";
698
705
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: !isHidden && hasItems ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(
699
706
  "div",
700
707
  {
701
- className: `propeller-product-bulk-prices ${props.className || ""}`,
708
+ className: cn(`propeller-product-bulk-prices ${props.className || ""}`),
702
709
  "data-include-tax": includeTax ? "true" : "false",
703
710
  children: [
704
- propellerV2CoreUi.getLabel(props.labels, "title", "Volume pricing") ? /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "propeller-product-bulk-prices__title text-base font-semibold text-foreground mb-3", children: propellerV2CoreUi.getLabel(props.labels, "title", "Volume pricing") }) : null,
711
+ title ? /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "propeller-product-bulk-prices__title text-base font-semibold text-foreground mb-3", children: title }) : null,
705
712
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "propeller-product-bulk-prices__table-wrapper overflow-hidden rounded-container border border-border", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "propeller-product-bulk-prices__table w-full text-sm", children: [
706
713
  /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "propeller-product-bulk-prices__thead bg-muted/50", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
707
714
  /* @__PURE__ */ jsxRuntime.jsx("th", { className: "propeller-product-bulk-prices__th propeller-product-bulk-prices__th--quantity px-4 py-2 text-left font-medium text-muted-foreground", children: propellerV2CoreUi.getLabel(props.labels, "quantityFrom", "Qty from") }),
@@ -738,7 +745,7 @@ function ProductDownloads(props) {
738
745
  const match = alts.find((a) => a.language === lang);
739
746
  return match?.value || alts?.[0]?.value || "Download";
740
747
  }
741
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `propeller-product-downloads ${props.className || ""}`, children: [
748
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(`propeller-product-downloads ${props.className || ""}`), children: [
742
749
  hasItems ? /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "propeller-product-downloads__title text-base font-semibold text-foreground mb-3", children: propellerV2CoreUi.getLabel(props.labels, "title", "Downloads") }) : null,
743
750
  hasItems ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "propeller-product-downloads__list space-y-2", children: items.map((doc, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "propeller-product-downloads__item", children: !!getDocumentUrl(doc) ? /* @__PURE__ */ jsxRuntime.jsxs(
744
751
  "a",
@@ -798,7 +805,7 @@ function ProductPriceDisplay(props) {
798
805
  }
799
806
  function formatPrice5(value) {
800
807
  if (value === null || value === void 0) return "";
801
- return propellerV2CoreUi.formatPrice(value, { symbol: props.currency ?? "\u20AC" });
808
+ return propellerV2CoreUi.formatPrice(value, { symbol: props.currency ?? "\u20AC", locale: propellerV2CoreUi.localeForLanguage(props.language) });
802
809
  }
803
810
  function getOptionsTotal(useNet) {
804
811
  const options = props.options || [];
@@ -841,7 +848,7 @@ function ProductPriceDisplay(props) {
841
848
  function getSecondaryTaxLabel() {
842
849
  return props.includeTax ? propellerV2CoreUi.getLabel(props.labels, "exclTax", "excl. VAT") : propellerV2CoreUi.getLabel(props.labels, "inclTax", "incl. VAT");
843
850
  }
844
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `propeller-product-price ${props.className || ""}`, "data-hidden": isHidden() ? "true" : "false", children: [
851
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(`propeller-product-price ${props.className || ""}`), "data-hidden": isHidden() ? "true" : "false", children: [
845
852
  isHidden() && props.showLoginPrompt !== false ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "propeller-product-price__login-prompt text-sm text-muted-foreground italic", children: propellerV2CoreUi.getLabel(props.labels, "loginToSeePrices", "Log in to see prices") }) : null,
846
853
  !isHidden() && !!getLeadingPrice() ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "propeller-product-price__content flex flex-col gap-0.5", children: [
847
854
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "propeller-product-price__primary flex items-baseline gap-2", children: [
@@ -875,7 +882,7 @@ function ProductShortDescription(props) {
875
882
  "div",
876
883
  {
877
884
  dangerouslySetInnerHTML: { __html: html },
878
- className: `propeller-product-short-description prose prose-slate max-w-none text-muted-foreground ${props.className || ""}`
885
+ className: cn(`propeller-product-short-description prose prose-slate max-w-none text-muted-foreground ${props.className || ""}`)
879
886
  }
880
887
  ) : null });
881
888
  }
@@ -918,7 +925,7 @@ function ProductVideos(props) {
918
925
  }
919
926
  return uri;
920
927
  }
921
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `propeller-product-videos ${props.className || ""}`, children: [
928
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(`propeller-product-videos ${props.className || ""}`), children: [
922
929
  hasItems ? /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "propeller-product-videos__title text-base font-semibold text-foreground mb-3", children: propellerV2CoreUi.getLabel(props.labels, "title", "Videos") }) : null,
923
930
  hasItems ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "propeller-product-videos__list space-y-4", children: items.map((video, index) => /* @__PURE__ */ jsxRuntime.jsx(
924
931
  "div",