@sprintup-cms/sdk 1.8.18 → 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.
@@ -2,7 +2,7 @@ import { NextResponse } from 'next/server';
2
2
  import { revalidateTag, revalidatePath } from 'next/cache';
3
3
  import { draftMode, cookies } from 'next/headers';
4
4
  import { notFound } from 'next/navigation';
5
- import React from 'react';
5
+ import React, { useState } from 'react';
6
6
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
7
7
 
8
8
  /* @sprintup-cms/sdk — https://forgecms.io */
@@ -614,6 +614,184 @@ function CMSBlocks({ blocks, pageType, className = "", custom = {} }) {
614
614
  return /* @__PURE__ */ jsx(SectionBlock, { block, pageType }, block.id);
615
615
  }) });
616
616
  }
617
+ function StarIcon() {
618
+ return /* @__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" }) });
619
+ }
620
+ function GridIcon({ active }) {
621
+ return /* @__PURE__ */ jsxs(
622
+ "svg",
623
+ {
624
+ viewBox: "0 0 16 16",
625
+ className: `w-4 h-4 ${active ? "text-foreground" : "text-muted-foreground"}`,
626
+ fill: "currentColor",
627
+ children: [
628
+ /* @__PURE__ */ jsx("rect", { x: "1", y: "1", width: "6", height: "6", rx: "1" }),
629
+ /* @__PURE__ */ jsx("rect", { x: "9", y: "1", width: "6", height: "6", rx: "1" }),
630
+ /* @__PURE__ */ jsx("rect", { x: "1", y: "9", width: "6", height: "6", rx: "1" }),
631
+ /* @__PURE__ */ jsx("rect", { x: "9", y: "9", width: "6", height: "6", rx: "1" })
632
+ ]
633
+ }
634
+ );
635
+ }
636
+ function ListIcon({ active }) {
637
+ return /* @__PURE__ */ jsxs(
638
+ "svg",
639
+ {
640
+ viewBox: "0 0 16 16",
641
+ className: `w-4 h-4 ${active ? "text-foreground" : "text-muted-foreground"}`,
642
+ fill: "currentColor",
643
+ children: [
644
+ /* @__PURE__ */ jsx("rect", { x: "1", y: "2", width: "14", height: "3", rx: "1" }),
645
+ /* @__PURE__ */ jsx("rect", { x: "1", y: "7", width: "14", height: "3", rx: "1" }),
646
+ /* @__PURE__ */ jsx("rect", { x: "1", y: "12", width: "14", height: "3", rx: "1" })
647
+ ]
648
+ }
649
+ );
650
+ }
651
+ function ProductCard({ product, cardStyle, showPrice, showRating, currency, ctaLabel, staticCtaUrl }) {
652
+ const accentColor = product.color ?? "#6366f1";
653
+ const href = staticCtaUrl || product.ctaUrl;
654
+ return /* @__PURE__ */ jsxs(
655
+ "div",
656
+ {
657
+ 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"}`,
658
+ children: [
659
+ cardStyle === "color-band" && /* @__PURE__ */ jsx("div", { className: "h-2 w-full flex-shrink-0", style: { backgroundColor: accentColor } }),
660
+ 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 }) }),
661
+ /* @__PURE__ */ jsxs("div", { className: "p-5 flex flex-col gap-3 flex-1", children: [
662
+ cardStyle !== "filled-header" && (product.category || product.badge) && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
663
+ product.category && /* @__PURE__ */ jsx("span", { className: "text-xs px-2 py-0.5 rounded-full font-medium text-white", style: { backgroundColor: accentColor }, children: product.category }),
664
+ product.badge && /* @__PURE__ */ jsx("span", { className: "text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground", children: product.badge })
665
+ ] }),
666
+ 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 }),
667
+ /* @__PURE__ */ jsx("h3", { className: "font-semibold text-base line-clamp-2", children: product.name }),
668
+ product.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground line-clamp-2", children: product.description }),
669
+ /* @__PURE__ */ jsxs("div", { className: "mt-auto pt-3 border-t border-border flex items-center justify-between gap-3", children: [
670
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
671
+ showPrice && product.price > 0 && /* @__PURE__ */ jsxs("span", { className: "font-bold text-lg", children: [
672
+ product.price.toFixed(2),
673
+ " ",
674
+ currency
675
+ ] }),
676
+ showRating && product.rating && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground", children: [
677
+ /* @__PURE__ */ jsx(StarIcon, {}),
678
+ /* @__PURE__ */ jsx("span", { children: product.rating })
679
+ ] })
680
+ ] }),
681
+ ctaLabel && /* @__PURE__ */ jsx(
682
+ "a",
683
+ {
684
+ href: href || "#",
685
+ className: "text-xs font-semibold px-3 py-1.5 rounded-lg text-white transition-opacity hover:opacity-90 flex-shrink-0",
686
+ style: { backgroundColor: accentColor },
687
+ children: ctaLabel
688
+ }
689
+ )
690
+ ] })
691
+ ] })
692
+ ]
693
+ }
694
+ );
695
+ }
696
+ function ProductRow({ product, showPrice, showRating, currency, ctaLabel, staticCtaUrl }) {
697
+ const accentColor = product.color ?? "#6366f1";
698
+ const href = staticCtaUrl || product.ctaUrl;
699
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 border rounded-xl bg-card px-5 py-4 hover:shadow-md transition-shadow group", children: [
700
+ /* @__PURE__ */ jsx("div", { className: "w-1 self-stretch rounded-full flex-shrink-0", style: { backgroundColor: accentColor } }),
701
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
702
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-wrap mb-1", children: [
703
+ product.category && /* @__PURE__ */ jsx("span", { className: "text-xs px-2 py-0.5 rounded-full font-medium text-white", style: { backgroundColor: accentColor }, children: product.category }),
704
+ product.badge && /* @__PURE__ */ jsx("span", { className: "text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground", children: product.badge })
705
+ ] }),
706
+ /* @__PURE__ */ jsx("h3", { className: "font-semibold text-sm truncate", children: product.name }),
707
+ product.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground truncate mt-0.5", children: product.description })
708
+ ] }),
709
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 flex-shrink-0", children: [
710
+ showRating && product.rating && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground", children: [
711
+ /* @__PURE__ */ jsx(StarIcon, {}),
712
+ /* @__PURE__ */ jsx("span", { children: product.rating })
713
+ ] }),
714
+ showPrice && product.price > 0 && /* @__PURE__ */ jsxs("span", { className: "font-bold text-base", children: [
715
+ product.price.toFixed(2),
716
+ " ",
717
+ currency
718
+ ] }),
719
+ ctaLabel && /* @__PURE__ */ jsx(
720
+ "a",
721
+ {
722
+ href: href || "#",
723
+ className: "text-xs font-semibold px-3 py-1.5 rounded-lg text-white transition-opacity hover:opacity-90",
724
+ style: { backgroundColor: accentColor },
725
+ children: ctaLabel
726
+ }
727
+ )
728
+ ] })
729
+ ] });
730
+ }
731
+ function ProductListClient({
732
+ products,
733
+ defaultLayout,
734
+ allowToggle,
735
+ gridCols,
736
+ cardStyle,
737
+ showPrice,
738
+ showRating,
739
+ currency,
740
+ ctaLabel,
741
+ staticCtaUrl
742
+ }) {
743
+ const [layout, setLayout] = useState(defaultLayout);
744
+ return /* @__PURE__ */ jsxs("div", { children: [
745
+ allowToggle && /* @__PURE__ */ jsx("div", { className: "flex justify-end mb-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 border border-border rounded-lg p-1 bg-muted/30", children: [
746
+ /* @__PURE__ */ jsx(
747
+ "button",
748
+ {
749
+ type: "button",
750
+ onClick: () => setLayout("grid"),
751
+ className: `p-1.5 rounded-md transition-colors ${layout === "grid" ? "bg-background shadow-sm" : "hover:bg-muted"}`,
752
+ "aria-label": "Grid view",
753
+ "aria-pressed": layout === "grid",
754
+ children: /* @__PURE__ */ jsx(GridIcon, { active: layout === "grid" })
755
+ }
756
+ ),
757
+ /* @__PURE__ */ jsx(
758
+ "button",
759
+ {
760
+ type: "button",
761
+ onClick: () => setLayout("list"),
762
+ className: `p-1.5 rounded-md transition-colors ${layout === "list" ? "bg-background shadow-sm" : "hover:bg-muted"}`,
763
+ "aria-label": "List view",
764
+ "aria-pressed": layout === "list",
765
+ children: /* @__PURE__ */ jsx(ListIcon, { active: layout === "list" })
766
+ }
767
+ )
768
+ ] }) }),
769
+ layout === "grid" ? /* @__PURE__ */ jsx("div", { className: `grid gap-6 grid-cols-1 ${gridCols}`, children: products.map((product) => /* @__PURE__ */ jsx(
770
+ ProductCard,
771
+ {
772
+ product,
773
+ cardStyle,
774
+ showPrice,
775
+ showRating,
776
+ currency,
777
+ ctaLabel,
778
+ staticCtaUrl
779
+ },
780
+ product.id
781
+ )) }) : /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3", children: products.map((product) => /* @__PURE__ */ jsx(
782
+ ProductRow,
783
+ {
784
+ product,
785
+ showPrice,
786
+ showRating,
787
+ currency,
788
+ ctaLabel,
789
+ staticCtaUrl
790
+ },
791
+ product.id
792
+ )) })
793
+ ] });
794
+ }
617
795
  function resolvePath(obj, path) {
618
796
  if (!path) return void 0;
619
797
  return path.split(/[\.\[\]]+/).filter(Boolean).reduce((acc, key) => acc?.[key], obj);
@@ -654,6 +832,8 @@ function ServerProductListBlock({ block }) {
654
832
  cardStyle = "color-band",
655
833
  ctaLabel = "",
656
834
  ctaUrl: staticCtaUrl = "",
835
+ defaultLayout = "grid",
836
+ allowToggle = true,
657
837
  fieldTitle,
658
838
  fieldPrice,
659
839
  fieldColor,
@@ -675,59 +855,21 @@ function ServerProductListBlock({ block }) {
675
855
  title && /* @__PURE__ */ jsx("h2", { className: "text-2xl md:text-3xl font-semibold tracking-tight text-balance", children: title }),
676
856
  subtitle && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground mt-2 text-pretty", children: subtitle })
677
857
  ] }),
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
- }) })
858
+ /* @__PURE__ */ jsx(
859
+ ProductListClient,
860
+ {
861
+ products,
862
+ defaultLayout,
863
+ allowToggle,
864
+ gridCols,
865
+ cardStyle,
866
+ showPrice,
867
+ showRating,
868
+ currency,
869
+ ctaLabel,
870
+ staticCtaUrl
871
+ }
872
+ )
731
873
  ] }) });
732
874
  }
733
875
  var client = createCMSClient();