@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.js
CHANGED
|
@@ -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__ */
|
|
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
|
-
|
|
495
|
-
|
|
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-
|
|
498
|
-
|
|
499
|
-
|
|
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
|
|
617
|
-
if (
|
|
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;
|
|
620
|
-
const
|
|
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:
|
|
624
|
-
price:
|
|
625
|
-
|
|
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
|
|
628
|
-
badge
|
|
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 {
|
|
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) =>
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
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();
|