@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.
- package/dist/next/index.cjs +108 -43
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +108 -43
- package/dist/next/index.js.map +1 -1
- package/dist/react/index.cjs +11 -10
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +11 -10
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/next/index.cjs
CHANGED
|
@@ -491,18 +491,19 @@ function ProductListBlock({ block }) {
|
|
|
491
491
|
title && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl md:text-3xl font-semibold tracking-tight", children: title }),
|
|
492
492
|
subtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground mt-2", children: subtitle })
|
|
493
493
|
] }),
|
|
494
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `grid gap-6 grid-cols-1 ${gridCols}`, children: products.map((product) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border rounded-lg overflow-hidden group hover:shadow-md transition-shadow", children: [
|
|
495
|
-
/* @__PURE__ */ jsxRuntime.
|
|
496
|
-
product.image ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: product.image, alt: product.name, className: "w-full h-full object-cover group-hover:scale-105 transition-transform duration-300" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full flex items-center justify-center text-muted-foreground/30", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-12 h-12", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z" }) }) }),
|
|
497
|
-
product.badge && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute top-3 left-3 text-xs px-2 py-1 rounded bg-primary text-primary-foreground", children: product.badge })
|
|
498
|
-
] }),
|
|
494
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `grid gap-6 grid-cols-1 ${gridCols}`, children: products.map((product) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border rounded-lg overflow-hidden group hover:shadow-md transition-shadow bg-card", children: [
|
|
495
|
+
product.image && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aspect-video relative bg-muted overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: product.image, alt: product.name, className: "w-full h-full object-cover group-hover:scale-105 transition-transform duration-300" }) }),
|
|
499
496
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4 space-y-2", children: [
|
|
500
|
-
|
|
501
|
-
|
|
497
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
|
|
498
|
+
product.category && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs px-2 py-0.5 rounded-full bg-primary/10 text-primary font-medium", children: product.category }),
|
|
499
|
+
product.badge && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground", children: product.badge })
|
|
500
|
+
] }),
|
|
501
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-semibold text-base line-clamp-2", children: product.name }),
|
|
502
502
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between pt-1", children: [
|
|
503
|
-
showPrice && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-
|
|
504
|
-
|
|
505
|
-
|
|
503
|
+
showPrice && product.price > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-bold text-lg", children: [
|
|
504
|
+
typeof product.price === "number" ? product.price.toFixed(2) : product.price,
|
|
505
|
+
" ",
|
|
506
|
+
currency
|
|
506
507
|
] }),
|
|
507
508
|
showRating && product.rating && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground", children: [
|
|
508
509
|
/* @__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" }) }),
|
|
@@ -619,56 +620,120 @@ function CMSBlocks({ blocks, pageType, className = "", custom = {} }) {
|
|
|
619
620
|
return /* @__PURE__ */ jsxRuntime.jsx(SectionBlock, { block, pageType }, block.id);
|
|
620
621
|
}) });
|
|
621
622
|
}
|
|
622
|
-
function
|
|
623
|
-
if (
|
|
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;
|
|
626
|
-
const
|
|
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;
|
|
627
638
|
return {
|
|
628
639
|
id: raw._id ?? raw.id ?? String(Math.random()),
|
|
629
|
-
name:
|
|
630
|
-
price:
|
|
631
|
-
|
|
640
|
+
name: String(name),
|
|
641
|
+
price: typeof rawPrice === "number" ? rawPrice : parseFloat(String(rawPrice)) || 0,
|
|
642
|
+
color: color ? String(color) : void 0,
|
|
632
643
|
rating: raw.rating ?? void 0,
|
|
633
|
-
category
|
|
634
|
-
badge
|
|
644
|
+
category,
|
|
645
|
+
badge,
|
|
646
|
+
description: description ? String(description) : void 0,
|
|
647
|
+
ctaUrl: ctaUrl ? String(ctaUrl) : void 0
|
|
635
648
|
};
|
|
636
649
|
}
|
|
637
650
|
function ServerProductListBlock({ block }) {
|
|
638
651
|
const cfg = block.content ?? {};
|
|
639
|
-
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 };
|
|
640
672
|
const cols = parseInt(String(columns), 10);
|
|
641
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";
|
|
642
674
|
const rawProducts = Array.isArray(block._resolvedProducts) ? block._resolvedProducts : Array.isArray(cfg.prefetchedProducts) ? cfg.prefetchedProducts : [];
|
|
643
|
-
const products = rawProducts.map(normaliseProductServer).slice(0, Number(limit));
|
|
675
|
+
const products = rawProducts.map((r) => normaliseProductServer(r, fm)).slice(0, Number(limit));
|
|
644
676
|
if (products.length === 0) {
|
|
645
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" }) }) }) });
|
|
646
678
|
}
|
|
647
679
|
return /* @__PURE__ */ jsxRuntime.jsx("section", { className: "py-12", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-6xl mx-auto px-4", children: [
|
|
648
680
|
(title || subtitle) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center mb-8", children: [
|
|
649
|
-
title && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl md:text-3xl font-semibold tracking-tight", children: title }),
|
|
650
|
-
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 })
|
|
651
683
|
] }),
|
|
652
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `grid gap-6 grid-cols-1 ${gridCols}`, children: products.map((product) =>
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
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(
|
|
688
|
+
"div",
|
|
689
|
+
{
|
|
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
|
+
}) })
|
|
672
737
|
] }) });
|
|
673
738
|
}
|
|
674
739
|
var client = createCMSClient();
|