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