@sprintup-cms/sdk 1.8.16 → 1.8.18
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/next/index.cjs +95 -43
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +95 -43
- package/dist/next/index.js.map +1 -1
- package/package.json +1 -1
package/dist/next/index.js
CHANGED
|
@@ -614,68 +614,120 @@ function CMSBlocks({ blocks, pageType, className = "", custom = {} }) {
|
|
|
614
614
|
return /* @__PURE__ */ jsx(SectionBlock, { block, pageType }, block.id);
|
|
615
615
|
}) });
|
|
616
616
|
}
|
|
617
|
-
function
|
|
618
|
-
|
|
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;
|
|
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;
|
|
620
632
|
return {
|
|
621
633
|
id: raw._id ?? raw.id ?? String(Math.random()),
|
|
622
|
-
name:
|
|
623
|
-
price:
|
|
624
|
-
color:
|
|
634
|
+
name: String(name),
|
|
635
|
+
price: typeof rawPrice === "number" ? rawPrice : parseFloat(String(rawPrice)) || 0,
|
|
636
|
+
color: color ? String(color) : void 0,
|
|
625
637
|
rating: raw.rating ?? void 0,
|
|
626
|
-
category
|
|
627
|
-
badge
|
|
638
|
+
category,
|
|
639
|
+
badge,
|
|
640
|
+
description: description ? String(description) : void 0,
|
|
641
|
+
ctaUrl: ctaUrl ? String(ctaUrl) : void 0
|
|
628
642
|
};
|
|
629
643
|
}
|
|
630
644
|
function ServerProductListBlock({ block }) {
|
|
631
645
|
const cfg = block.content ?? {};
|
|
632
|
-
const {
|
|
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 };
|
|
633
666
|
const cols = parseInt(String(columns), 10);
|
|
634
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";
|
|
635
668
|
const rawProducts = Array.isArray(block._resolvedProducts) ? block._resolvedProducts : Array.isArray(cfg.prefetchedProducts) ? cfg.prefetchedProducts : [];
|
|
636
|
-
const products = rawProducts.map(normaliseProductServer).slice(0, Number(limit));
|
|
669
|
+
const products = rawProducts.map((r) => normaliseProductServer(r, fm)).slice(0, Number(limit));
|
|
637
670
|
if (products.length === 0) {
|
|
638
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" }) }) }) });
|
|
639
672
|
}
|
|
640
673
|
return /* @__PURE__ */ jsx("section", { className: "py-12", children: /* @__PURE__ */ jsxs("div", { className: "max-w-6xl mx-auto px-4", children: [
|
|
641
674
|
(title || subtitle) && /* @__PURE__ */ jsxs("div", { className: "text-center mb-8", children: [
|
|
642
|
-
title && /* @__PURE__ */ jsx("h2", { className: "text-2xl md:text-3xl font-semibold tracking-tight", children: title }),
|
|
643
|
-
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 })
|
|
644
677
|
] }),
|
|
645
|
-
/* @__PURE__ */ jsx("div", { className: `grid gap-6 grid-cols-1 ${gridCols}`, children: products.map((product) =>
|
|
646
|
-
|
|
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(
|
|
647
682
|
"div",
|
|
648
683
|
{
|
|
649
|
-
className: "
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
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
|
+
}) })
|
|
679
731
|
] }) });
|
|
680
732
|
}
|
|
681
733
|
var client = createCMSClient();
|