@sprintup-cms/sdk 1.8.15 → 1.8.17

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.
@@ -485,18 +485,19 @@ function ProductListBlock({ block }) {
485
485
  title && /* @__PURE__ */ jsx("h2", { className: "text-2xl md:text-3xl font-semibold tracking-tight", children: title }),
486
486
  subtitle && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground mt-2", children: subtitle })
487
487
  ] }),
488
- /* @__PURE__ */ jsx("div", { className: `grid gap-6 grid-cols-1 ${gridCols}`, children: products.map((product) => /* @__PURE__ */ jsxs("div", { className: "border rounded-lg overflow-hidden group hover:shadow-md transition-shadow", children: [
489
- /* @__PURE__ */ jsxs("div", { className: "aspect-square relative bg-muted overflow-hidden", children: [
490
- product.image ? /* @__PURE__ */ jsx("img", { src: product.image, alt: product.name, className: "w-full h-full object-cover group-hover:scale-105 transition-transform duration-300" }) : /* @__PURE__ */ jsx("div", { className: "w-full h-full flex items-center justify-center text-muted-foreground/30", children: /* @__PURE__ */ jsx("svg", { className: "w-12 h-12", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z" }) }) }),
491
- product.badge && /* @__PURE__ */ jsx("span", { className: "absolute top-3 left-3 text-xs px-2 py-1 rounded bg-primary text-primary-foreground", children: product.badge })
492
- ] }),
488
+ /* @__PURE__ */ jsx("div", { className: `grid gap-6 grid-cols-1 ${gridCols}`, children: products.map((product) => /* @__PURE__ */ jsxs("div", { className: "border rounded-lg overflow-hidden group hover:shadow-md transition-shadow bg-card", children: [
489
+ product.image && /* @__PURE__ */ jsx("div", { className: "aspect-video relative bg-muted overflow-hidden", children: /* @__PURE__ */ jsx("img", { src: product.image, alt: product.name, className: "w-full h-full object-cover group-hover:scale-105 transition-transform duration-300" }) }),
493
490
  /* @__PURE__ */ jsxs("div", { className: "p-4 space-y-2", children: [
494
- product.category && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground uppercase tracking-wide", children: product.category }),
495
- /* @__PURE__ */ jsx("h3", { className: "font-medium text-sm line-clamp-2", children: product.name }),
491
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
492
+ product.category && /* @__PURE__ */ jsx("span", { className: "text-xs px-2 py-0.5 rounded-full bg-primary/10 text-primary font-medium", children: product.category }),
493
+ product.badge && /* @__PURE__ */ jsx("span", { className: "text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground", children: product.badge })
494
+ ] }),
495
+ /* @__PURE__ */ jsx("h3", { className: "font-semibold text-base line-clamp-2", children: product.name }),
496
496
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pt-1", children: [
497
- showPrice && /* @__PURE__ */ jsxs("span", { className: "font-semibold", children: [
498
- currency,
499
- typeof product.price === "number" ? product.price.toFixed(2) : product.price
497
+ showPrice && product.price > 0 && /* @__PURE__ */ jsxs("span", { className: "font-bold text-lg", children: [
498
+ typeof product.price === "number" ? product.price.toFixed(2) : product.price,
499
+ " ",
500
+ currency
500
501
  ] }),
501
502
  showRating && product.rating && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground", children: [
502
503
  /* @__PURE__ */ jsx("svg", { className: "w-3.5 h-3.5 fill-yellow-400 text-yellow-400", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { d: "M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" }) }),
@@ -613,56 +614,120 @@ function CMSBlocks({ blocks, pageType, className = "", custom = {} }) {
613
614
  return /* @__PURE__ */ jsx(SectionBlock, { block, pageType }, block.id);
614
615
  }) });
615
616
  }
616
- function normaliseProductServer(raw) {
617
- if (raw.id !== void 0 && raw.price !== void 0) return raw;
618
- const firstPlan = Array.isArray(raw.plans) && raw.plans.length > 0 ? raw.plans[0] : null;
617
+ function resolvePath(obj, path) {
618
+ if (!path) return void 0;
619
+ return path.split(/[\.\[\]]+/).filter(Boolean).reduce((acc, key) => acc?.[key], obj);
620
+ }
621
+ function normaliseProductServer(raw, fm) {
622
+ const name = resolvePath(raw, fm.fieldTitle || "") ?? raw.name ?? "Unnamed";
623
+ const rawPrice = resolvePath(raw, fm.fieldPrice || "") ?? (Array.isArray(raw.plans) ? raw.plans[0]?.price : void 0) ?? raw.price ?? 0;
624
+ const color = resolvePath(raw, fm.fieldColor || "") ?? raw.primaryColor ?? raw.color ?? void 0;
625
+ const rawCategory = resolvePath(raw, fm.fieldCategory || "") ?? raw.type ?? void 0;
626
+ const rawBadge = resolvePath(raw, fm.fieldBadge || "") ?? void 0;
627
+ const description = resolvePath(raw, fm.fieldDescription || "") ?? raw.description ?? void 0;
628
+ const ctaUrl = resolvePath(raw, fm.fieldCtaUrl || "") ?? raw.url ?? raw.link ?? void 0;
619
629
  const courseCount = Array.isArray(raw.courses) ? raw.courses.length : void 0;
620
- const image = raw.image && !raw.image.startsWith("data:") ? raw.image : raw.thumbnail ?? void 0;
630
+ const badge = rawBadge != null ? String(rawBadge) : courseCount ? `${courseCount} course${courseCount !== 1 ? "s" : ""}` : raw.duration ? `${raw.duration} min` : void 0;
631
+ const category = rawCategory ? String(rawCategory).replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()) : void 0;
621
632
  return {
622
633
  id: raw._id ?? raw.id ?? String(Math.random()),
623
- name: raw.name ?? "Unnamed",
624
- price: firstPlan?.price ?? raw.price ?? 0,
625
- image,
634
+ name: String(name),
635
+ price: typeof rawPrice === "number" ? rawPrice : parseFloat(String(rawPrice)) || 0,
636
+ color: color ? String(color) : void 0,
626
637
  rating: raw.rating ?? void 0,
627
- category: raw.type ? raw.type.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()) : void 0,
628
- badge: courseCount ? `${courseCount} course${courseCount !== 1 ? "s" : ""}` : raw.duration ? `${raw.duration} min` : void 0
638
+ category,
639
+ badge,
640
+ description: description ? String(description) : void 0,
641
+ ctaUrl: ctaUrl ? String(ctaUrl) : void 0
629
642
  };
630
643
  }
631
644
  function ServerProductListBlock({ block }) {
632
645
  const cfg = block.content ?? {};
633
- const { title, subtitle, columns = 3, showPrice = true, showRating = true, limit = 6, currency = "$" } = cfg;
646
+ const {
647
+ title,
648
+ subtitle,
649
+ columns = 3,
650
+ showPrice = true,
651
+ showRating = true,
652
+ limit = 6,
653
+ currency = "$",
654
+ cardStyle = "color-band",
655
+ ctaLabel = "",
656
+ ctaUrl: staticCtaUrl = "",
657
+ fieldTitle,
658
+ fieldPrice,
659
+ fieldColor,
660
+ fieldCategory,
661
+ fieldBadge,
662
+ fieldDescription,
663
+ fieldCtaUrl
664
+ } = cfg;
665
+ const fm = { fieldTitle, fieldPrice, fieldColor, fieldCategory, fieldBadge, fieldDescription, fieldCtaUrl };
634
666
  const cols = parseInt(String(columns), 10);
635
667
  const gridCols = cols === 2 ? "sm:grid-cols-2" : cols === 4 ? "sm:grid-cols-2 lg:grid-cols-4" : "sm:grid-cols-2 lg:grid-cols-3";
636
668
  const rawProducts = Array.isArray(block._resolvedProducts) ? block._resolvedProducts : Array.isArray(cfg.prefetchedProducts) ? cfg.prefetchedProducts : [];
637
- const products = rawProducts.map(normaliseProductServer).slice(0, Number(limit));
669
+ const products = rawProducts.map((r) => normaliseProductServer(r, fm)).slice(0, Number(limit));
638
670
  if (products.length === 0) {
639
671
  return /* @__PURE__ */ jsx("section", { className: "py-12", children: /* @__PURE__ */ jsx("div", { className: "max-w-6xl mx-auto px-4", children: /* @__PURE__ */ jsx("div", { className: "text-center py-12 border border-dashed border-border rounded-lg bg-muted/10", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "No products available" }) }) }) });
640
672
  }
641
673
  return /* @__PURE__ */ jsx("section", { className: "py-12", children: /* @__PURE__ */ jsxs("div", { className: "max-w-6xl mx-auto px-4", children: [
642
674
  (title || subtitle) && /* @__PURE__ */ jsxs("div", { className: "text-center mb-8", children: [
643
- title && /* @__PURE__ */ jsx("h2", { className: "text-2xl md:text-3xl font-semibold tracking-tight", children: title }),
644
- subtitle && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground mt-2", children: subtitle })
675
+ title && /* @__PURE__ */ jsx("h2", { className: "text-2xl md:text-3xl font-semibold tracking-tight text-balance", children: title }),
676
+ subtitle && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground mt-2 text-pretty", children: subtitle })
645
677
  ] }),
646
- /* @__PURE__ */ jsx("div", { className: `grid gap-6 grid-cols-1 ${gridCols}`, children: products.map((product) => /* @__PURE__ */ jsxs("div", { className: "border rounded-lg overflow-hidden group hover:shadow-md transition-shadow", children: [
647
- /* @__PURE__ */ jsxs("div", { className: "aspect-square relative bg-muted overflow-hidden", children: [
648
- product.image ? /* @__PURE__ */ jsx("img", { src: product.image, alt: product.name, className: "w-full h-full object-cover group-hover:scale-105 transition-transform duration-300" }) : /* @__PURE__ */ jsx("div", { className: "w-full h-full flex items-center justify-center text-muted-foreground/30", children: /* @__PURE__ */ jsx("svg", { className: "w-12 h-12", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z" }) }) }),
649
- product.badge && /* @__PURE__ */ jsx("span", { className: "absolute top-3 left-3 text-xs px-2 py-1 rounded bg-primary text-primary-foreground", children: product.badge })
650
- ] }),
651
- /* @__PURE__ */ jsxs("div", { className: "p-4 space-y-2", children: [
652
- product.category && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground uppercase tracking-wide", children: product.category }),
653
- /* @__PURE__ */ jsx("h3", { className: "font-medium text-sm line-clamp-2", children: product.name }),
654
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pt-1", children: [
655
- showPrice && /* @__PURE__ */ jsxs("span", { className: "font-semibold", children: [
656
- currency,
657
- typeof product.price === "number" ? product.price.toFixed(2) : product.price
658
- ] }),
659
- showRating && product.rating && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground", children: [
660
- /* @__PURE__ */ jsx("svg", { className: "w-3.5 h-3.5 fill-yellow-400 text-yellow-400", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { d: "M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" }) }),
661
- /* @__PURE__ */ jsx("span", { children: product.rating })
662
- ] })
663
- ] })
664
- ] })
665
- ] }, product.id)) })
678
+ /* @__PURE__ */ jsx("div", { className: `grid gap-6 grid-cols-1 ${gridCols}`, children: products.map((product) => {
679
+ const accentColor = product.color ?? "#6366f1";
680
+ const href = staticCtaUrl || product.ctaUrl;
681
+ return /* @__PURE__ */ jsxs(
682
+ "div",
683
+ {
684
+ className: `overflow-hidden group transition-shadow flex flex-col ${cardStyle === "minimal" ? "border-0 shadow-none bg-transparent" : "border rounded-xl hover:shadow-lg bg-card"}`,
685
+ children: [
686
+ cardStyle === "color-band" && /* @__PURE__ */ jsx("div", { className: "h-2 w-full flex-shrink-0", style: { backgroundColor: accentColor } }),
687
+ cardStyle === "filled-header" && /* @__PURE__ */ jsx("div", { className: "h-20 w-full flex-shrink-0 flex items-end px-5 pb-3", style: { backgroundColor: accentColor }, children: product.category && /* @__PURE__ */ jsx("span", { className: "text-xs font-semibold text-white/80 uppercase tracking-wider", children: product.category }) }),
688
+ /* @__PURE__ */ jsxs("div", { className: "p-5 flex flex-col gap-3 flex-1", children: [
689
+ cardStyle !== "filled-header" && (product.category || product.badge) && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
690
+ product.category && /* @__PURE__ */ jsx(
691
+ "span",
692
+ {
693
+ className: "text-xs px-2 py-0.5 rounded-full font-medium text-white",
694
+ style: { backgroundColor: accentColor },
695
+ children: product.category
696
+ }
697
+ ),
698
+ product.badge && /* @__PURE__ */ jsx("span", { className: "text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground", children: product.badge })
699
+ ] }),
700
+ cardStyle === "filled-header" && product.badge && /* @__PURE__ */ jsx("span", { className: "text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground self-start", children: product.badge }),
701
+ /* @__PURE__ */ jsx("h3", { className: "font-semibold text-base line-clamp-2", children: product.name }),
702
+ product.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground line-clamp-2", children: product.description }),
703
+ /* @__PURE__ */ jsxs("div", { className: "mt-auto pt-3 border-t border-border flex items-center justify-between gap-3", children: [
704
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
705
+ showPrice && product.price > 0 && /* @__PURE__ */ jsxs("span", { className: "font-bold text-lg", children: [
706
+ product.price.toFixed(2),
707
+ " ",
708
+ currency
709
+ ] }),
710
+ showRating && product.rating && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground", children: [
711
+ /* @__PURE__ */ jsx("svg", { className: "w-3.5 h-3.5 fill-yellow-400 text-yellow-400", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { d: "M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" }) }),
712
+ /* @__PURE__ */ jsx("span", { children: product.rating })
713
+ ] })
714
+ ] }),
715
+ ctaLabel && /* @__PURE__ */ jsx(
716
+ "a",
717
+ {
718
+ href: href || "#",
719
+ className: "text-xs font-semibold px-3 py-1.5 rounded-lg text-white transition-opacity hover:opacity-90 flex-shrink-0",
720
+ style: { backgroundColor: accentColor },
721
+ children: ctaLabel
722
+ }
723
+ )
724
+ ] })
725
+ ] })
726
+ ]
727
+ },
728
+ product.id
729
+ );
730
+ }) })
666
731
  ] }) });
667
732
  }
668
733
  var client = createCMSClient();