@sprintup-cms/sdk 1.8.56 → 1.8.59

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.
@@ -269,7 +269,7 @@ function createCMSClient(options) {
269
269
  try {
270
270
  const res = await fetch(`${baseUrl}/api/v1/${appId}/globals`, {
271
271
  headers: headers(),
272
- next: { revalidate: 300, tags: [`cms-globals-${appId}`] }
272
+ next: { revalidate: 60, tags: [`cms-globals-${appId}`] }
273
273
  });
274
274
  if (!res.ok) {
275
275
  const [navPages, footerPages] = await Promise.all([
@@ -1151,97 +1151,117 @@ function ServerProductListBlock({ block }) {
1151
1151
  }) })
1152
1152
  ] }) });
1153
1153
  }
1154
- function parseNavItems(html) {
1155
- if (!html) return [];
1156
- const text = html.replace(/<[^>]*>/g, "").replace(/&nbsp;/g, " ");
1157
- return text.split(/\r?\n/).filter(Boolean).map((line) => {
1158
- const [label, url] = line.split("|").map((s) => s.trim());
1159
- return { label: label || "", url: url || "#" };
1160
- });
1154
+ function getSD(doc) {
1155
+ const structuredBlock = Array.isArray(doc?.blocks) && doc.blocks[0]?.type === "__structured__" ? doc.blocks[0].content : null;
1156
+ return doc?.sectionData ?? structuredBlock ?? null;
1161
1157
  }
1162
1158
  function CMSHeader({ nav }) {
1163
- if (!nav) return null;
1164
- const structuredBlock = nav.blocks?.[0]?.type === "__structured__" ? nav.blocks[0].content : null;
1165
- const primary = nav.sectionData?.primary ?? structuredBlock?.primary ?? {};
1166
- const navItems = parseNavItems(primary.nav_items || "");
1167
- const logoUrl = primary.logo_url || "";
1168
- const logoAlt = primary.logo_alt || "";
1169
- if (!logoUrl && !logoAlt && navItems.length === 0) return null;
1170
- return /* @__PURE__ */ jsxRuntime.jsx("header", { className: "w-full border-b border-border bg-background/95 backdrop-blur sticky top-0 z-50", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-6xl mx-auto px-4 h-16 flex items-center justify-between gap-4", children: [
1171
- /* @__PURE__ */ jsxRuntime.jsxs("a", { href: "/", className: "flex items-center gap-2 shrink-0", children: [
1172
- logoUrl && /* @__PURE__ */ jsxRuntime.jsx("img", { src: logoUrl, alt: logoAlt || "Logo", className: "h-8 w-auto" }),
1173
- !logoUrl && logoAlt && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-bold text-base", children: logoAlt })
1174
- ] }),
1175
- navItems.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("nav", { className: "hidden md:flex items-center gap-6", children: navItems.map((item, i) => /* @__PURE__ */ jsxRuntime.jsx("a", { href: item.url, className: "text-sm text-muted-foreground hover:text-foreground transition-colors", children: item.label }, i)) })
1159
+ const sd = getSD(nav);
1160
+ if (!sd) return null;
1161
+ const logoUrl = sd.logo_url?.trim() || "";
1162
+ const logoAlt = sd.logo_alt?.trim() || "";
1163
+ const items = Array.isArray(sd.items) ? sd.items : [];
1164
+ if (!logoUrl && !logoAlt && items.length === 0) return null;
1165
+ const links = items.filter((i) => i.type === "link" || i.type === "dropdown");
1166
+ const buttons = items.filter((i) => i.type === "button");
1167
+ const btnBase = { textDecoration: "none", padding: "0.4rem 1rem", borderRadius: "6px", fontWeight: 600, fontSize: "0.875rem", whiteSpace: "nowrap", transition: "opacity 0.15s" };
1168
+ const btnVariant = (v) => ({
1169
+ primary: { ...btnBase, background: "var(--foreground, #111)", color: "#fff", border: "1px solid transparent" },
1170
+ outline: { ...btnBase, background: "transparent", color: "var(--foreground, #111)", border: "1px solid var(--border, #e5e7eb)" },
1171
+ ghost: { ...btnBase, background: "transparent", color: "var(--muted-foreground, #6b7280)", border: "none", fontWeight: 500 }
1172
+ })[v] ?? btnBase;
1173
+ return /* @__PURE__ */ jsxRuntime.jsx("header", { style: { position: "sticky", top: 0, zIndex: 50, width: "100%", borderBottom: "1px solid var(--border, #e5e7eb)", background: "rgba(255,255,255,0.97)", backdropFilter: "blur(8px)", WebkitBackdropFilter: "blur(8px)" }, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { maxWidth: "1200px", margin: "0 auto", padding: "0 1.5rem", height: "64px", display: "flex", alignItems: "center", justifyContent: "space-between", gap: "2rem" }, children: [
1174
+ /* @__PURE__ */ jsxRuntime.jsx("a", { href: "/", style: { display: "flex", alignItems: "center", gap: "0.5rem", textDecoration: "none", flexShrink: 0 }, children: logoUrl ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: logoUrl, alt: logoAlt || "Logo", style: { height: "32px", width: "auto", display: "block" } }) : /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 700, fontSize: "1.125rem", color: "var(--foreground, #111)" }, children: logoAlt }) }),
1175
+ links.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("nav", { style: { display: "flex", alignItems: "center", gap: "1.75rem", flex: 1 }, children: links.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
1176
+ "a",
1177
+ {
1178
+ href: item.url || "#",
1179
+ target: item.openInNewTab ? "_blank" : void 0,
1180
+ rel: item.openInNewTab ? "noopener noreferrer" : void 0,
1181
+ style: { fontSize: "0.9rem", color: "var(--muted-foreground, #6b7280)", textDecoration: "none", fontWeight: 500 },
1182
+ children: item.label
1183
+ },
1184
+ item.id
1185
+ )) }),
1186
+ buttons.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", alignItems: "center", gap: "0.625rem", flexShrink: 0 }, children: buttons.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
1187
+ "a",
1188
+ {
1189
+ href: item.url || "#",
1190
+ target: item.openInNewTab ? "_blank" : void 0,
1191
+ rel: item.openInNewTab ? "noopener noreferrer" : void 0,
1192
+ style: btnVariant(item.variant || "ghost"),
1193
+ children: item.label
1194
+ },
1195
+ item.id
1196
+ )) })
1176
1197
  ] }) });
1177
1198
  }
1178
- function parseFooterColumns(html) {
1179
- if (!html) return [];
1180
- const text = html.replace(/<[^>]*>/g, "").replace(/&nbsp;/g, " ");
1181
- const lines = text.split(/\r?\n/).filter(Boolean);
1182
- const cols = [];
1183
- let current = null;
1184
- for (const line of lines) {
1185
- const parts = line.split("|").map((s) => s.trim());
1186
- if (parts.length === 1) {
1187
- if (current) cols.push(current);
1188
- current = { title: parts[0], links: [] };
1189
- } else if (parts.length >= 2) {
1190
- if (!current) current = { title: "", links: [] };
1191
- current.links.push({ label: parts[0], url: parts[1] || "#" });
1192
- }
1193
- }
1194
- if (current) cols.push(current);
1195
- return cols;
1196
- }
1197
- function parseLegalLinks(html) {
1198
- if (!html) return [];
1199
- const text = html.replace(/<[^>]*>/g, "").replace(/&nbsp;/g, " ");
1200
- return text.split(/\r?\n/).filter(Boolean).map((line) => {
1201
- const [label, url] = line.split("|").map((s) => s.trim());
1202
- return { label: label || "", url: url || "#" };
1203
- });
1204
- }
1199
+ var SOCIAL_ICONS = [
1200
+ { key: "facebook", label: "Facebook", d: "M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z" },
1201
+ { key: "twitter", label: "X", d: "M18 6L6 18M6 6l12 12" },
1202
+ { key: "instagram", label: "Instagram", d: "M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37zm1.5-4.87h.01M6.5 2h11A4.5 4.5 0 0 1 22 6.5v11A4.5 4.5 0 0 1 17.5 22h-11A4.5 4.5 0 0 1 2 17.5v-11A4.5 4.5 0 0 1 6.5 2z" },
1203
+ { key: "linkedin", label: "LinkedIn", d: "M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-4 0v7h-4v-7a6 6 0 0 1 6-6zM2 9h4v12H2zm2-3a2 2 0 1 1 0-4 2 2 0 0 1 0 4z" },
1204
+ { key: "youtube", label: "YouTube", d: "M22.54 6.42a2.78 2.78 0 0 0-1.94-1.96C18.88 4 12 4 12 4s-6.88 0-8.6.46a2.78 2.78 0 0 0-1.94 1.96A29 29 0 0 0 1 12a29 29 0 0 0 .46 5.58 2.78 2.78 0 0 0 1.94 1.96C5.12 20 12 20 12 20s6.88 0 8.6-.46a2.78 2.78 0 0 0 1.94-1.96A29 29 0 0 0 23 12a29 29 0 0 0-.46-5.58zM9.75 15.02V8.98L15.5 12l-5.75 3.02z" }
1205
+ ];
1205
1206
  function CMSFooter({ footer }) {
1206
- if (!footer) return null;
1207
- const structuredBlock = footer.blocks?.[0]?.type === "__structured__" ? footer.blocks[0].content : null;
1208
- const sd = footer.sectionData ?? structuredBlock ?? {};
1209
- const c = sd.content ?? {};
1210
- const contact = sd.contact ?? {};
1211
- const social = sd.social ?? {};
1212
- const legal = sd.legal ?? {};
1213
- const columns = parseFooterColumns(c.columns || "");
1214
- const legalLinks = parseLegalLinks(legal.legal_links || "");
1215
- const hasSocial = social.facebook || social.twitter || social.instagram || social.linkedin || social.youtube;
1216
- const isEmpty = !c.tagline && !c.logo_url && columns.length === 0 && !contact.email && !contact.phone && !hasSocial && !legal.copyright && legalLinks.length === 0;
1217
- if (isEmpty) return null;
1218
- return /* @__PURE__ */ jsxRuntime.jsx("footer", { className: "border-t border-border bg-muted/30 pt-12 pb-6 mt-16", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-6xl mx-auto px-4", children: [
1219
- (c.tagline || c.logo_url || columns.length > 0 || contact.email) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `grid gap-8 mb-10 grid-cols-1 sm:grid-cols-2 ${columns.length > 0 ? "lg:grid-cols-4" : "lg:grid-cols-2"}`, children: [
1220
- (c.logo_url || c.tagline) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
1221
- c.logo_url && /* @__PURE__ */ jsxRuntime.jsx("img", { src: c.logo_url, alt: "Logo", className: "h-8 w-auto" }),
1222
- c.tagline && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground leading-relaxed", children: c.tagline })
1207
+ const sd = getSD(footer);
1208
+ if (!sd) return null;
1209
+ const brand = sd.brand || {};
1210
+ const columns = Array.isArray(sd.columns) ? sd.columns : [];
1211
+ const social = sd.social || {};
1212
+ const contact = sd.contact || {};
1213
+ const legal = sd.legal || {};
1214
+ const hasBrand = brand.logo_url || brand.tagline;
1215
+ const hasContact = contact.email || contact.phone || contact.address;
1216
+ const hasSocial = SOCIAL_ICONS.some((s) => social[s.key]?.trim());
1217
+ const hasBottom = legal.copyright || Array.isArray(legal.links) && legal.links.length > 0;
1218
+ const hasContent = hasBrand || columns.length > 0 || hasContact;
1219
+ if (!hasContent && !hasSocial && !hasBottom) return null;
1220
+ const totalCols = [hasBrand, ...columns.map(() => true), hasContact].filter(Boolean).length;
1221
+ const gridCols = totalCols <= 1 ? "1fr" : totalCols === 2 ? "repeat(2,1fr)" : totalCols === 3 ? "repeat(3,1fr)" : "repeat(4,1fr)";
1222
+ const mutedLink = { fontSize: "0.875rem", color: "var(--muted-foreground, #6b7280)", textDecoration: "none" };
1223
+ return /* @__PURE__ */ jsxRuntime.jsx("footer", { style: { borderTop: "1px solid var(--border, #e5e7eb)", background: "var(--muted, #f9fafb)", marginTop: "4rem" }, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { maxWidth: "1200px", margin: "0 auto", padding: "3rem 1.5rem 1.5rem" }, children: [
1224
+ hasContent && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "grid", gridTemplateColumns: gridCols, gap: "2.5rem", marginBottom: hasSocial || hasBottom ? "2.5rem" : 0 }, children: [
1225
+ hasBrand && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: [
1226
+ brand.logo_url && /* @__PURE__ */ jsxRuntime.jsx("img", { src: brand.logo_url, alt: "Logo", style: { height: "32px", width: "auto", objectFit: "contain" } }),
1227
+ brand.tagline && /* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: "0.875rem", color: "var(--muted-foreground, #6b7280)", lineHeight: 1.6, margin: 0 }, children: brand.tagline })
1223
1228
  ] }),
1224
- columns.map((col, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1225
- col.title && /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "font-semibold text-sm mb-3", children: col.title }),
1226
- /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-2", children: col.links.map((link, j) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: link.url, className: "text-sm text-muted-foreground hover:text-foreground transition-colors", children: link.label }) }, j)) })
1227
- ] }, i)),
1228
- (contact.email || contact.phone || contact.address) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
1229
- /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "font-semibold text-sm mb-3", children: "Contact" }),
1230
- contact.email && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: contact.email }),
1231
- contact.phone && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: contact.phone }),
1232
- contact.address && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground whitespace-pre-line", children: contact.address })
1229
+ columns.map((col) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1230
+ col.title && /* @__PURE__ */ jsxRuntime.jsx("h4", { style: { fontWeight: 600, fontSize: "0.875rem", margin: "0 0 0.875rem", color: "var(--foreground, #111)" }, children: col.title }),
1231
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { style: { listStyle: "none", margin: 0, padding: 0, display: "flex", flexDirection: "column", gap: "0.5rem" }, children: (col.links || []).filter((l) => l.label).map((link) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: link.url || "#", style: mutedLink, children: link.label }) }, link.id || link.label)) })
1232
+ ] }, col.id || col.title)),
1233
+ hasContact && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1234
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { style: { fontWeight: 600, fontSize: "0.875rem", margin: "0 0 0.875rem", color: "var(--foreground, #111)" }, children: "Contact" }),
1235
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "0.4rem" }, children: [
1236
+ contact.email && /* @__PURE__ */ jsxRuntime.jsx("a", { href: `mailto:${contact.email}`, style: mutedLink, children: contact.email }),
1237
+ contact.phone && /* @__PURE__ */ jsxRuntime.jsx("a", { href: `tel:${contact.phone}`, style: mutedLink, children: contact.phone }),
1238
+ contact.address && /* @__PURE__ */ jsxRuntime.jsx("p", { style: { ...mutedLink, whiteSpace: "pre-line", margin: 0 }, children: contact.address })
1239
+ ] })
1233
1240
  ] })
1234
1241
  ] }),
1235
- hasSocial && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-4 mb-6", children: [
1236
- social.facebook && /* @__PURE__ */ jsxRuntime.jsx("a", { href: social.facebook, className: "text-sm text-muted-foreground hover:text-foreground transition-colors", children: "Facebook" }),
1237
- social.twitter && /* @__PURE__ */ jsxRuntime.jsx("a", { href: social.twitter, className: "text-sm text-muted-foreground hover:text-foreground transition-colors", children: "X" }),
1238
- social.instagram && /* @__PURE__ */ jsxRuntime.jsx("a", { href: social.instagram, className: "text-sm text-muted-foreground hover:text-foreground transition-colors", children: "Instagram" }),
1239
- social.linkedin && /* @__PURE__ */ jsxRuntime.jsx("a", { href: social.linkedin, className: "text-sm text-muted-foreground hover:text-foreground transition-colors", children: "LinkedIn" }),
1240
- social.youtube && /* @__PURE__ */ jsxRuntime.jsx("a", { href: social.youtube, className: "text-sm text-muted-foreground hover:text-foreground transition-colors", children: "YouTube" })
1241
- ] }),
1242
- (legal.copyright || legalLinks.length > 0) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center justify-between gap-4 pt-6 border-t border-border", children: [
1243
- legal.copyright && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: legal.copyright }),
1244
- legalLinks.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-4", children: legalLinks.map((link, i) => /* @__PURE__ */ jsxRuntime.jsx("a", { href: link.url, className: "text-xs text-muted-foreground hover:text-foreground transition-colors", children: link.label }, i)) })
1242
+ hasSocial && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", gap: "0.75rem", marginBottom: hasBottom ? "1.5rem" : 0 }, children: SOCIAL_ICONS.filter((s) => social[s.key]?.trim()).map((s) => /* @__PURE__ */ jsxRuntime.jsx(
1243
+ "a",
1244
+ {
1245
+ href: social[s.key],
1246
+ target: "_blank",
1247
+ rel: "noopener noreferrer",
1248
+ "aria-label": s.label,
1249
+ style: { display: "flex", alignItems: "center", justifyContent: "center", width: "36px", height: "36px", borderRadius: "8px", border: "1px solid var(--border, #e5e7eb)", color: "var(--muted-foreground, #6b7280)", textDecoration: "none", flexShrink: 0 },
1250
+ children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: s.d }) })
1251
+ },
1252
+ s.key
1253
+ )) }),
1254
+ hasBottom && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { borderTop: "1px solid var(--border, #e5e7eb)", paddingTop: "1.25rem", display: "flex", flexWrap: "wrap", alignItems: "center", justifyContent: "space-between", gap: "1rem" }, children: [
1255
+ legal.copyright && /* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: "0.8rem", color: "var(--muted-foreground, #6b7280)", margin: 0 }, children: legal.copyright }),
1256
+ Array.isArray(legal.links) && legal.links.filter((l) => l.label).length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: "1.25rem" }, children: legal.links.filter((l) => l.label).map((link) => /* @__PURE__ */ jsxRuntime.jsx(
1257
+ "a",
1258
+ {
1259
+ href: link.url || "#",
1260
+ style: { fontSize: "0.8rem", color: "var(--muted-foreground, #6b7280)", textDecoration: "none" },
1261
+ children: link.label
1262
+ },
1263
+ link.id || link.label
1264
+ )) })
1245
1265
  ] })
1246
1266
  ] }) });
1247
1267
  }