@sprintup-cms/sdk 1.8.19 → 1.8.20
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 +195 -60
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +196 -61
- package/dist/next/index.js.map +1 -1
- package/package.json +1 -1
package/dist/next/index.cjs
CHANGED
|
@@ -620,6 +620,184 @@ function CMSBlocks({ blocks, pageType, className = "", custom = {} }) {
|
|
|
620
620
|
return /* @__PURE__ */ jsxRuntime.jsx(SectionBlock, { block, pageType }, block.id);
|
|
621
621
|
}) });
|
|
622
622
|
}
|
|
623
|
+
function StarIcon() {
|
|
624
|
+
return /* @__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" }) });
|
|
625
|
+
}
|
|
626
|
+
function GridIcon({ active }) {
|
|
627
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
628
|
+
"svg",
|
|
629
|
+
{
|
|
630
|
+
viewBox: "0 0 16 16",
|
|
631
|
+
className: `w-4 h-4 ${active ? "text-foreground" : "text-muted-foreground"}`,
|
|
632
|
+
fill: "currentColor",
|
|
633
|
+
children: [
|
|
634
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "1", y: "1", width: "6", height: "6", rx: "1" }),
|
|
635
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "1", width: "6", height: "6", rx: "1" }),
|
|
636
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "1", y: "9", width: "6", height: "6", rx: "1" }),
|
|
637
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "6", height: "6", rx: "1" })
|
|
638
|
+
]
|
|
639
|
+
}
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
function ListIcon({ active }) {
|
|
643
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
644
|
+
"svg",
|
|
645
|
+
{
|
|
646
|
+
viewBox: "0 0 16 16",
|
|
647
|
+
className: `w-4 h-4 ${active ? "text-foreground" : "text-muted-foreground"}`,
|
|
648
|
+
fill: "currentColor",
|
|
649
|
+
children: [
|
|
650
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "1", y: "2", width: "14", height: "3", rx: "1" }),
|
|
651
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "1", y: "7", width: "14", height: "3", rx: "1" }),
|
|
652
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "1", y: "12", width: "14", height: "3", rx: "1" })
|
|
653
|
+
]
|
|
654
|
+
}
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
function ProductCard({ product, cardStyle, showPrice, showRating, currency, ctaLabel, staticCtaUrl }) {
|
|
658
|
+
const accentColor = product.color ?? "#6366f1";
|
|
659
|
+
const href = staticCtaUrl || product.ctaUrl;
|
|
660
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
661
|
+
"div",
|
|
662
|
+
{
|
|
663
|
+
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"}`,
|
|
664
|
+
children: [
|
|
665
|
+
cardStyle === "color-band" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-2 w-full flex-shrink-0", style: { backgroundColor: accentColor } }),
|
|
666
|
+
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 }) }),
|
|
667
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-5 flex flex-col gap-3 flex-1", children: [
|
|
668
|
+
cardStyle !== "filled-header" && (product.category || product.badge) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
|
|
669
|
+
product.category && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs px-2 py-0.5 rounded-full font-medium text-white", style: { backgroundColor: accentColor }, children: product.category }),
|
|
670
|
+
product.badge && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground", children: product.badge })
|
|
671
|
+
] }),
|
|
672
|
+
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 }),
|
|
673
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-semibold text-base line-clamp-2", children: product.name }),
|
|
674
|
+
product.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground line-clamp-2", children: product.description }),
|
|
675
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-auto pt-3 border-t border-border flex items-center justify-between gap-3", children: [
|
|
676
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
677
|
+
showPrice && product.price > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-bold text-lg", children: [
|
|
678
|
+
product.price.toFixed(2),
|
|
679
|
+
" ",
|
|
680
|
+
currency
|
|
681
|
+
] }),
|
|
682
|
+
showRating && product.rating && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground", children: [
|
|
683
|
+
/* @__PURE__ */ jsxRuntime.jsx(StarIcon, {}),
|
|
684
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: product.rating })
|
|
685
|
+
] })
|
|
686
|
+
] }),
|
|
687
|
+
ctaLabel && /* @__PURE__ */ jsxRuntime.jsx(
|
|
688
|
+
"a",
|
|
689
|
+
{
|
|
690
|
+
href: href || "#",
|
|
691
|
+
className: "text-xs font-semibold px-3 py-1.5 rounded-lg text-white transition-opacity hover:opacity-90 flex-shrink-0",
|
|
692
|
+
style: { backgroundColor: accentColor },
|
|
693
|
+
children: ctaLabel
|
|
694
|
+
}
|
|
695
|
+
)
|
|
696
|
+
] })
|
|
697
|
+
] })
|
|
698
|
+
]
|
|
699
|
+
}
|
|
700
|
+
);
|
|
701
|
+
}
|
|
702
|
+
function ProductRow({ product, showPrice, showRating, currency, ctaLabel, staticCtaUrl }) {
|
|
703
|
+
const accentColor = product.color ?? "#6366f1";
|
|
704
|
+
const href = staticCtaUrl || product.ctaUrl;
|
|
705
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4 border rounded-xl bg-card px-5 py-4 hover:shadow-md transition-shadow group", children: [
|
|
706
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-1 self-stretch rounded-full flex-shrink-0", style: { backgroundColor: accentColor } }),
|
|
707
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
708
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 flex-wrap mb-1", children: [
|
|
709
|
+
product.category && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs px-2 py-0.5 rounded-full font-medium text-white", style: { backgroundColor: accentColor }, children: product.category }),
|
|
710
|
+
product.badge && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground", children: product.badge })
|
|
711
|
+
] }),
|
|
712
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-semibold text-sm truncate", children: product.name }),
|
|
713
|
+
product.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground truncate mt-0.5", children: product.description })
|
|
714
|
+
] }),
|
|
715
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4 flex-shrink-0", children: [
|
|
716
|
+
showRating && product.rating && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground", children: [
|
|
717
|
+
/* @__PURE__ */ jsxRuntime.jsx(StarIcon, {}),
|
|
718
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: product.rating })
|
|
719
|
+
] }),
|
|
720
|
+
showPrice && product.price > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-bold text-base", children: [
|
|
721
|
+
product.price.toFixed(2),
|
|
722
|
+
" ",
|
|
723
|
+
currency
|
|
724
|
+
] }),
|
|
725
|
+
ctaLabel && /* @__PURE__ */ jsxRuntime.jsx(
|
|
726
|
+
"a",
|
|
727
|
+
{
|
|
728
|
+
href: href || "#",
|
|
729
|
+
className: "text-xs font-semibold px-3 py-1.5 rounded-lg text-white transition-opacity hover:opacity-90",
|
|
730
|
+
style: { backgroundColor: accentColor },
|
|
731
|
+
children: ctaLabel
|
|
732
|
+
}
|
|
733
|
+
)
|
|
734
|
+
] })
|
|
735
|
+
] });
|
|
736
|
+
}
|
|
737
|
+
function ProductListClient({
|
|
738
|
+
products,
|
|
739
|
+
defaultLayout,
|
|
740
|
+
allowToggle,
|
|
741
|
+
gridCols,
|
|
742
|
+
cardStyle,
|
|
743
|
+
showPrice,
|
|
744
|
+
showRating,
|
|
745
|
+
currency,
|
|
746
|
+
ctaLabel,
|
|
747
|
+
staticCtaUrl
|
|
748
|
+
}) {
|
|
749
|
+
const [layout, setLayout] = React.useState(defaultLayout);
|
|
750
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
751
|
+
allowToggle && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end mb-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 border border-border rounded-lg p-1 bg-muted/30", children: [
|
|
752
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
753
|
+
"button",
|
|
754
|
+
{
|
|
755
|
+
type: "button",
|
|
756
|
+
onClick: () => setLayout("grid"),
|
|
757
|
+
className: `p-1.5 rounded-md transition-colors ${layout === "grid" ? "bg-background shadow-sm" : "hover:bg-muted"}`,
|
|
758
|
+
"aria-label": "Grid view",
|
|
759
|
+
"aria-pressed": layout === "grid",
|
|
760
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(GridIcon, { active: layout === "grid" })
|
|
761
|
+
}
|
|
762
|
+
),
|
|
763
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
764
|
+
"button",
|
|
765
|
+
{
|
|
766
|
+
type: "button",
|
|
767
|
+
onClick: () => setLayout("list"),
|
|
768
|
+
className: `p-1.5 rounded-md transition-colors ${layout === "list" ? "bg-background shadow-sm" : "hover:bg-muted"}`,
|
|
769
|
+
"aria-label": "List view",
|
|
770
|
+
"aria-pressed": layout === "list",
|
|
771
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ListIcon, { active: layout === "list" })
|
|
772
|
+
}
|
|
773
|
+
)
|
|
774
|
+
] }) }),
|
|
775
|
+
layout === "grid" ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: `grid gap-6 grid-cols-1 ${gridCols}`, children: products.map((product) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
776
|
+
ProductCard,
|
|
777
|
+
{
|
|
778
|
+
product,
|
|
779
|
+
cardStyle,
|
|
780
|
+
showPrice,
|
|
781
|
+
showRating,
|
|
782
|
+
currency,
|
|
783
|
+
ctaLabel,
|
|
784
|
+
staticCtaUrl
|
|
785
|
+
},
|
|
786
|
+
product.id
|
|
787
|
+
)) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-3", children: products.map((product) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
788
|
+
ProductRow,
|
|
789
|
+
{
|
|
790
|
+
product,
|
|
791
|
+
showPrice,
|
|
792
|
+
showRating,
|
|
793
|
+
currency,
|
|
794
|
+
ctaLabel,
|
|
795
|
+
staticCtaUrl
|
|
796
|
+
},
|
|
797
|
+
product.id
|
|
798
|
+
)) })
|
|
799
|
+
] });
|
|
800
|
+
}
|
|
623
801
|
function resolvePath(obj, path) {
|
|
624
802
|
if (!path) return void 0;
|
|
625
803
|
return path.split(/[\.\[\]]+/).filter(Boolean).reduce((acc, key) => acc?.[key], obj);
|
|
@@ -660,6 +838,8 @@ function ServerProductListBlock({ block }) {
|
|
|
660
838
|
cardStyle = "color-band",
|
|
661
839
|
ctaLabel = "",
|
|
662
840
|
ctaUrl: staticCtaUrl = "",
|
|
841
|
+
defaultLayout = "grid",
|
|
842
|
+
allowToggle = true,
|
|
663
843
|
fieldTitle,
|
|
664
844
|
fieldPrice,
|
|
665
845
|
fieldColor,
|
|
@@ -669,13 +849,6 @@ function ServerProductListBlock({ block }) {
|
|
|
669
849
|
fieldCtaUrl
|
|
670
850
|
} = cfg;
|
|
671
851
|
const fm = { fieldTitle, fieldPrice, fieldColor, fieldCategory, fieldBadge, fieldDescription, fieldCtaUrl };
|
|
672
|
-
console.log("[v0] ServerProductListBlock cfg keys:", Object.keys(cfg));
|
|
673
|
-
console.log("[v0] ServerProductListBlock fm:", JSON.stringify(fm));
|
|
674
|
-
console.log("[v0] ServerProductListBlock rawProducts count:", Array.isArray(block._resolvedProducts) ? block._resolvedProducts.length : "none", "| prefetched:", Array.isArray(cfg.prefetchedProducts) ? cfg.prefetchedProducts.length : "none");
|
|
675
|
-
if (Array.isArray(cfg.prefetchedProducts) && cfg.prefetchedProducts[0]) {
|
|
676
|
-
console.log("[v0] first product keys:", Object.keys(cfg.prefetchedProducts[0]));
|
|
677
|
-
console.log("[v0] first product sample:", JSON.stringify(cfg.prefetchedProducts[0]).slice(0, 300));
|
|
678
|
-
}
|
|
679
852
|
const cols = parseInt(String(columns), 10);
|
|
680
853
|
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";
|
|
681
854
|
const rawProducts = Array.isArray(block._resolvedProducts) ? block._resolvedProducts : Array.isArray(cfg.prefetchedProducts) ? cfg.prefetchedProducts : [];
|
|
@@ -688,59 +861,21 @@ function ServerProductListBlock({ block }) {
|
|
|
688
861
|
title && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl md:text-3xl font-semibold tracking-tight text-balance", children: title }),
|
|
689
862
|
subtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground mt-2 text-pretty", children: subtitle })
|
|
690
863
|
] }),
|
|
691
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
className: "text-xs px-2 py-0.5 rounded-full font-medium text-white",
|
|
707
|
-
style: { backgroundColor: accentColor },
|
|
708
|
-
children: product.category
|
|
709
|
-
}
|
|
710
|
-
),
|
|
711
|
-
product.badge && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground", children: product.badge })
|
|
712
|
-
] }),
|
|
713
|
-
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 }),
|
|
714
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-semibold text-base line-clamp-2", children: product.name }),
|
|
715
|
-
product.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground line-clamp-2", children: product.description }),
|
|
716
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-auto pt-3 border-t border-border flex items-center justify-between gap-3", children: [
|
|
717
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
718
|
-
showPrice && product.price > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-bold text-lg", children: [
|
|
719
|
-
product.price.toFixed(2),
|
|
720
|
-
" ",
|
|
721
|
-
currency
|
|
722
|
-
] }),
|
|
723
|
-
showRating && product.rating && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground", children: [
|
|
724
|
-
/* @__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" }) }),
|
|
725
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: product.rating })
|
|
726
|
-
] })
|
|
727
|
-
] }),
|
|
728
|
-
ctaLabel && /* @__PURE__ */ jsxRuntime.jsx(
|
|
729
|
-
"a",
|
|
730
|
-
{
|
|
731
|
-
href: href || "#",
|
|
732
|
-
className: "text-xs font-semibold px-3 py-1.5 rounded-lg text-white transition-opacity hover:opacity-90 flex-shrink-0",
|
|
733
|
-
style: { backgroundColor: accentColor },
|
|
734
|
-
children: ctaLabel
|
|
735
|
-
}
|
|
736
|
-
)
|
|
737
|
-
] })
|
|
738
|
-
] })
|
|
739
|
-
]
|
|
740
|
-
},
|
|
741
|
-
product.id
|
|
742
|
-
);
|
|
743
|
-
}) })
|
|
864
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
865
|
+
ProductListClient,
|
|
866
|
+
{
|
|
867
|
+
products,
|
|
868
|
+
defaultLayout,
|
|
869
|
+
allowToggle,
|
|
870
|
+
gridCols,
|
|
871
|
+
cardStyle,
|
|
872
|
+
showPrice,
|
|
873
|
+
showRating,
|
|
874
|
+
currency,
|
|
875
|
+
ctaLabel,
|
|
876
|
+
staticCtaUrl
|
|
877
|
+
}
|
|
878
|
+
)
|
|
744
879
|
] }) });
|
|
745
880
|
}
|
|
746
881
|
var client = createCMSClient();
|