@sprintup-cms/sdk 1.8.16 → 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.
- 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.cjs
CHANGED
|
@@ -620,68 +620,120 @@ function CMSBlocks({ blocks, pageType, className = "", custom = {} }) {
|
|
|
620
620
|
return /* @__PURE__ */ jsxRuntime.jsx(SectionBlock, { block, pageType }, block.id);
|
|
621
621
|
}) });
|
|
622
622
|
}
|
|
623
|
-
function
|
|
624
|
-
|
|
623
|
+
function resolvePath(obj, path) {
|
|
624
|
+
if (!path) return void 0;
|
|
625
|
+
return path.split(/[\.\[\]]+/).filter(Boolean).reduce((acc, key) => acc?.[key], obj);
|
|
626
|
+
}
|
|
627
|
+
function normaliseProductServer(raw, fm) {
|
|
628
|
+
const name = resolvePath(raw, fm.fieldTitle || "") ?? raw.name ?? "Unnamed";
|
|
629
|
+
const rawPrice = resolvePath(raw, fm.fieldPrice || "") ?? (Array.isArray(raw.plans) ? raw.plans[0]?.price : void 0) ?? raw.price ?? 0;
|
|
630
|
+
const color = resolvePath(raw, fm.fieldColor || "") ?? raw.primaryColor ?? raw.color ?? void 0;
|
|
631
|
+
const rawCategory = resolvePath(raw, fm.fieldCategory || "") ?? raw.type ?? void 0;
|
|
632
|
+
const rawBadge = resolvePath(raw, fm.fieldBadge || "") ?? void 0;
|
|
633
|
+
const description = resolvePath(raw, fm.fieldDescription || "") ?? raw.description ?? void 0;
|
|
634
|
+
const ctaUrl = resolvePath(raw, fm.fieldCtaUrl || "") ?? raw.url ?? raw.link ?? void 0;
|
|
625
635
|
const courseCount = Array.isArray(raw.courses) ? raw.courses.length : void 0;
|
|
636
|
+
const badge = rawBadge != null ? String(rawBadge) : courseCount ? `${courseCount} course${courseCount !== 1 ? "s" : ""}` : raw.duration ? `${raw.duration} min` : void 0;
|
|
637
|
+
const category = rawCategory ? String(rawCategory).replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()) : void 0;
|
|
626
638
|
return {
|
|
627
639
|
id: raw._id ?? raw.id ?? String(Math.random()),
|
|
628
|
-
name:
|
|
629
|
-
price:
|
|
630
|
-
color:
|
|
640
|
+
name: String(name),
|
|
641
|
+
price: typeof rawPrice === "number" ? rawPrice : parseFloat(String(rawPrice)) || 0,
|
|
642
|
+
color: color ? String(color) : void 0,
|
|
631
643
|
rating: raw.rating ?? void 0,
|
|
632
|
-
category
|
|
633
|
-
badge
|
|
644
|
+
category,
|
|
645
|
+
badge,
|
|
646
|
+
description: description ? String(description) : void 0,
|
|
647
|
+
ctaUrl: ctaUrl ? String(ctaUrl) : void 0
|
|
634
648
|
};
|
|
635
649
|
}
|
|
636
650
|
function ServerProductListBlock({ block }) {
|
|
637
651
|
const cfg = block.content ?? {};
|
|
638
|
-
const {
|
|
652
|
+
const {
|
|
653
|
+
title,
|
|
654
|
+
subtitle,
|
|
655
|
+
columns = 3,
|
|
656
|
+
showPrice = true,
|
|
657
|
+
showRating = true,
|
|
658
|
+
limit = 6,
|
|
659
|
+
currency = "$",
|
|
660
|
+
cardStyle = "color-band",
|
|
661
|
+
ctaLabel = "",
|
|
662
|
+
ctaUrl: staticCtaUrl = "",
|
|
663
|
+
fieldTitle,
|
|
664
|
+
fieldPrice,
|
|
665
|
+
fieldColor,
|
|
666
|
+
fieldCategory,
|
|
667
|
+
fieldBadge,
|
|
668
|
+
fieldDescription,
|
|
669
|
+
fieldCtaUrl
|
|
670
|
+
} = cfg;
|
|
671
|
+
const fm = { fieldTitle, fieldPrice, fieldColor, fieldCategory, fieldBadge, fieldDescription, fieldCtaUrl };
|
|
639
672
|
const cols = parseInt(String(columns), 10);
|
|
640
673
|
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";
|
|
641
674
|
const rawProducts = Array.isArray(block._resolvedProducts) ? block._resolvedProducts : Array.isArray(cfg.prefetchedProducts) ? cfg.prefetchedProducts : [];
|
|
642
|
-
const products = rawProducts.map(normaliseProductServer).slice(0, Number(limit));
|
|
675
|
+
const products = rawProducts.map((r) => normaliseProductServer(r, fm)).slice(0, Number(limit));
|
|
643
676
|
if (products.length === 0) {
|
|
644
677
|
return /* @__PURE__ */ jsxRuntime.jsx("section", { className: "py-12", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-6xl mx-auto px-4", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center py-12 border border-dashed border-border rounded-lg bg-muted/10", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "No products available" }) }) }) });
|
|
645
678
|
}
|
|
646
679
|
return /* @__PURE__ */ jsxRuntime.jsx("section", { className: "py-12", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-6xl mx-auto px-4", children: [
|
|
647
680
|
(title || subtitle) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center mb-8", children: [
|
|
648
|
-
title && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl md:text-3xl font-semibold tracking-tight", children: title }),
|
|
649
|
-
subtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground mt-2", children: subtitle })
|
|
681
|
+
title && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl md:text-3xl font-semibold tracking-tight text-balance", children: title }),
|
|
682
|
+
subtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground mt-2 text-pretty", children: subtitle })
|
|
650
683
|
] }),
|
|
651
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `grid gap-6 grid-cols-1 ${gridCols}`, children: products.map((product) =>
|
|
652
|
-
|
|
684
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `grid gap-6 grid-cols-1 ${gridCols}`, children: products.map((product) => {
|
|
685
|
+
const accentColor = product.color ?? "#6366f1";
|
|
686
|
+
const href = staticCtaUrl || product.ctaUrl;
|
|
687
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
653
688
|
"div",
|
|
654
689
|
{
|
|
655
|
-
className: "
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
690
|
+
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"}`,
|
|
691
|
+
children: [
|
|
692
|
+
cardStyle === "color-band" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-2 w-full flex-shrink-0", style: { backgroundColor: accentColor } }),
|
|
693
|
+
cardStyle === "filled-header" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-20 w-full flex-shrink-0 flex items-end px-5 pb-3", style: { backgroundColor: accentColor }, children: product.category && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-semibold text-white/80 uppercase tracking-wider", children: product.category }) }),
|
|
694
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-5 flex flex-col gap-3 flex-1", children: [
|
|
695
|
+
cardStyle !== "filled-header" && (product.category || product.badge) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
|
|
696
|
+
product.category && /* @__PURE__ */ jsxRuntime.jsx(
|
|
697
|
+
"span",
|
|
698
|
+
{
|
|
699
|
+
className: "text-xs px-2 py-0.5 rounded-full font-medium text-white",
|
|
700
|
+
style: { backgroundColor: accentColor },
|
|
701
|
+
children: product.category
|
|
702
|
+
}
|
|
703
|
+
),
|
|
704
|
+
product.badge && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground", children: product.badge })
|
|
705
|
+
] }),
|
|
706
|
+
cardStyle === "filled-header" && product.badge && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground self-start", children: product.badge }),
|
|
707
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-semibold text-base line-clamp-2", children: product.name }),
|
|
708
|
+
product.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground line-clamp-2", children: product.description }),
|
|
709
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-auto pt-3 border-t border-border flex items-center justify-between gap-3", children: [
|
|
710
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
711
|
+
showPrice && product.price > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-bold text-lg", children: [
|
|
712
|
+
product.price.toFixed(2),
|
|
713
|
+
" ",
|
|
714
|
+
currency
|
|
715
|
+
] }),
|
|
716
|
+
showRating && product.rating && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground", children: [
|
|
717
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-3.5 h-3.5 fill-yellow-400 text-yellow-400", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.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" }) }),
|
|
718
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: product.rating })
|
|
719
|
+
] })
|
|
720
|
+
] }),
|
|
721
|
+
ctaLabel && /* @__PURE__ */ jsxRuntime.jsx(
|
|
722
|
+
"a",
|
|
723
|
+
{
|
|
724
|
+
href: href || "#",
|
|
725
|
+
className: "text-xs font-semibold px-3 py-1.5 rounded-lg text-white transition-opacity hover:opacity-90 flex-shrink-0",
|
|
726
|
+
style: { backgroundColor: accentColor },
|
|
727
|
+
children: ctaLabel
|
|
728
|
+
}
|
|
729
|
+
)
|
|
730
|
+
] })
|
|
731
|
+
] })
|
|
732
|
+
]
|
|
733
|
+
},
|
|
734
|
+
product.id
|
|
735
|
+
);
|
|
736
|
+
}) })
|
|
685
737
|
] }) });
|
|
686
738
|
}
|
|
687
739
|
var client = createCMSClient();
|