@nuvler/cli 0.5.14 → 0.5.15

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.
@@ -1,4 +1,12 @@
1
- import { useEffect, useMemo, useRef, useState, type CSSProperties, type FormEvent, type ReactNode } from "react";
1
+ import {
2
+ useEffect,
3
+ useMemo,
4
+ useRef,
5
+ useState,
6
+ type CSSProperties,
7
+ type FormEvent,
8
+ type ReactNode,
9
+ } from "react";
2
10
  import type {
3
11
  ThemeCategory,
4
12
  ThemeBannerCarouselData,
@@ -36,12 +44,22 @@ const fallbackColors: ThemeSiteColors = {
36
44
 
37
45
  const template = {
38
46
  announcement: "Soluções, conteúdo e atendimento para o seu negócio",
39
- footerTagline: "Soluções, conteúdo e atendimento próximo para aproximar sua marca das pessoas.",
47
+ footerTagline:
48
+ "Soluções, conteúdo e atendimento próximo para aproximar sua marca das pessoas.",
40
49
  footerNote: "Conteúdo e atendimento que geram confiança",
41
50
  benefits: [
42
- { title: "Soluções sob medida", description: "Serviços pensados para o seu momento" },
43
- { title: "Conteúdo relevante", description: "Informação para ajudar nas decisões" },
44
- { title: "Atendimento próximo", description: "Fale diretamente com a empresa" },
51
+ {
52
+ title: "Soluções sob medida",
53
+ description: "Serviços pensados para o seu momento",
54
+ },
55
+ {
56
+ title: "Conteúdo relevante",
57
+ description: "Informação para ajudar nas decisões",
58
+ },
59
+ {
60
+ title: "Atendimento próximo",
61
+ description: "Fale diretamente com a empresa",
62
+ },
45
63
  ],
46
64
  };
47
65
 
@@ -52,7 +70,11 @@ const fallbackCatalog = {
52
70
  desktopColumns: 3 as const,
53
71
  };
54
72
 
55
- function dataString(data: Record<string, unknown>, field: string, fallback = ""): string {
73
+ function dataString(
74
+ data: Record<string, unknown>,
75
+ field: string,
76
+ fallback = "",
77
+ ): string {
56
78
  const value = data[field];
57
79
  return typeof value === "string" && value.trim() ? value.trim() : fallback;
58
80
  }
@@ -66,11 +88,19 @@ function plainText(value: string): string {
66
88
  return htmlToPlainText(value);
67
89
  }
68
90
 
69
- function moduleLinks(context: ThemeContext): Array<{ label: string; href: string }> {
91
+ function moduleLinks(
92
+ context: ThemeContext,
93
+ ): Array<{ label: string; href: string }> {
70
94
  return [
71
- ...(context.site.modules.includes("BLOG") ? [{ label: "Blog", href: "/blog" }] : []),
72
- ...(context.site.modules.includes("SERVICES") ? [{ label: "Serviços", href: "/servicos" }] : []),
73
- ...(context.site.modules.includes("CASES") ? [{ label: "Cases", href: "/cases" }] : []),
95
+ ...(context.site.modules.includes("BLOG")
96
+ ? [{ label: "Blog", href: "/blog" }]
97
+ : []),
98
+ ...(context.site.modules.includes("SERVICES")
99
+ ? [{ label: "Serviços", href: "/servicos" }]
100
+ : []),
101
+ ...(context.site.modules.includes("CASES")
102
+ ? [{ label: "Cases", href: "/cases" }]
103
+ : []),
74
104
  ...context.navigation.pages.slice(0, 6).map((page) => ({
75
105
  label: page.title,
76
106
  href: `/${page.slug}`,
@@ -97,9 +127,15 @@ function CategoryTree({
97
127
  return categories.map((category) => {
98
128
  const currentPath = [...path, category.slug];
99
129
  return (
100
- <div className="category-nav-tree-node" data-depth={depth} key={currentPath.join("/")}>
130
+ <div
131
+ className="category-nav-tree-node"
132
+ data-depth={depth}
133
+ key={currentPath.join("/")}
134
+ >
101
135
  <Link href={categoryUrl(currentPath)}>
102
- {depth > 0 && <span className="category-tree-branch" aria-hidden="true" />}
136
+ {depth > 0 && (
137
+ <span className="category-tree-branch" aria-hidden="true" />
138
+ )}
103
139
  <span>{category.name}</span>
104
140
  </Link>
105
141
  {category.children.length > 0 && (
@@ -116,20 +152,40 @@ function CategoryTree({
116
152
  }
117
153
 
118
154
  function displayPrice(product: ThemeProduct): string | null {
119
- const price = typeof product.promotionalPrice === "number" && typeof product.price === "number" && product.promotionalPrice < product.price
120
- ? product.promotionalPrice
121
- : product.price;
155
+ const price =
156
+ typeof product.promotionalPrice === "number" &&
157
+ typeof product.price === "number" &&
158
+ product.promotionalPrice < product.price
159
+ ? product.promotionalPrice
160
+ : product.price;
122
161
  return typeof price === "number"
123
- ? new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(price)
162
+ ? new Intl.NumberFormat("pt-BR", {
163
+ style: "currency",
164
+ currency: "BRL",
165
+ }).format(price)
124
166
  : null;
125
167
  }
126
168
 
127
169
  function originalPrice(product: ThemeProduct): string | null {
128
- if (typeof product.price !== "number" || typeof product.promotionalPrice !== "number" || product.promotionalPrice >= product.price) return null;
129
- return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(product.price);
170
+ if (
171
+ typeof product.price !== "number" ||
172
+ typeof product.promotionalPrice !== "number" ||
173
+ product.promotionalPrice >= product.price
174
+ )
175
+ return null;
176
+ return new Intl.NumberFormat("pt-BR", {
177
+ style: "currency",
178
+ currency: "BRL",
179
+ }).format(product.price);
130
180
  }
131
181
 
132
- function SmartSearch({ adapters, showPrices }: { adapters: ThemeRuntimeAdapters; showPrices: boolean }) {
182
+ function SmartSearch({
183
+ adapters,
184
+ showPrices,
185
+ }: {
186
+ adapters: ThemeRuntimeAdapters;
187
+ showPrices: boolean;
188
+ }) {
133
189
  const { Link, Image } = adapters;
134
190
  const [value, setValue] = useState("");
135
191
  const [results, setResults] = useState<ThemeProduct[]>([]);
@@ -143,11 +199,22 @@ function SmartSearch({ adapters, showPrices }: { adapters: ThemeRuntimeAdapters;
143
199
  let active = true;
144
200
  const timer = window.setTimeout(() => {
145
201
  setLoading(true);
146
- void adapters.searchProducts?.(query)
147
- .then((items) => { if (active) { setResults(items.slice(0, 5)); setOpen(true); } })
148
- .finally(() => { if (active) setLoading(false); });
202
+ void adapters
203
+ .searchProducts?.(query)
204
+ .then((items) => {
205
+ if (active) {
206
+ setResults(items.slice(0, 5));
207
+ setOpen(true);
208
+ }
209
+ })
210
+ .finally(() => {
211
+ if (active) setLoading(false);
212
+ });
149
213
  }, 280);
150
- return () => { active = false; window.clearTimeout(timer); };
214
+ return () => {
215
+ active = false;
216
+ window.clearTimeout(timer);
217
+ };
151
218
  }, [adapters, value]);
152
219
 
153
220
  useEffect(() => {
@@ -158,22 +225,70 @@ function SmartSearch({ adapters, showPrices }: { adapters: ThemeRuntimeAdapters;
158
225
  return () => document.removeEventListener("pointerdown", close);
159
226
  }, []);
160
227
 
161
- return <div className="header-search-shell" ref={root}>
162
- <form className="header-search" action="/produtos">
163
- <input name="busca" type="search" placeholder="O que você está procurando?" autoComplete="off" value={value} onChange={(event) => { const next = event.target.value; setValue(next); if (next.trim().length < 2) { setOpen(false); setResults([]); } }} onFocus={() => value.trim().length >= 2 && setOpen(true)} />
164
- <button type="submit" aria-label="Buscar"><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7" /><path d="m16.5 16.5 4 4" /></svg></button>
165
- </form>
166
- {open && value.trim().length >= 2 && <div className="search-suggestions">
167
- <div className="search-suggestions-heading"><strong>{loading ? "Buscando..." : "Produtos encontrados"}</strong>{!loading && <span>{results.length} de 5</span>}</div>
168
- {!loading && results.map((product) => <Link href={productUrl(product)} key={product.slug}>
169
- <span className="search-suggestion-image"><Image image={product.image} fallbackAlt={product.title} /></span>
170
- <span className="search-suggestion-copy"><strong>{product.title}</strong><small>{product.sku ? `Ref. ${product.sku}` : product.categories[0]?.name || "Produto"}</small></span>
171
- {showPrices && displayPrice(product) && <b>{displayPrice(product)}</b>}
172
- </Link>)}
173
- {!loading && !results.length && <p>Nenhum produto próximo foi encontrado.</p>}
174
- <Link className="search-all-results" href={`/produtos?busca=${encodeURIComponent(value.trim())}`}>Ver todos os resultados</Link>
175
- </div>}
176
- </div>;
228
+ return (
229
+ <div className="header-search-shell" ref={root}>
230
+ <form className="header-search" action="/produtos">
231
+ <input
232
+ name="busca"
233
+ type="search"
234
+ placeholder="O que você está procurando?"
235
+ autoComplete="off"
236
+ value={value}
237
+ onChange={(event) => {
238
+ const next = event.target.value;
239
+ setValue(next);
240
+ if (next.trim().length < 2) {
241
+ setOpen(false);
242
+ setResults([]);
243
+ }
244
+ }}
245
+ onFocus={() => value.trim().length >= 2 && setOpen(true)}
246
+ />
247
+ <button type="submit" aria-label="Buscar">
248
+ <svg viewBox="0 0 24 24" aria-hidden="true">
249
+ <circle cx="11" cy="11" r="7" />
250
+ <path d="m16.5 16.5 4 4" />
251
+ </svg>
252
+ </button>
253
+ </form>
254
+ {open && value.trim().length >= 2 && (
255
+ <div className="search-suggestions">
256
+ <div className="search-suggestions-heading">
257
+ <strong>{loading ? "Buscando..." : "Produtos encontrados"}</strong>
258
+ {!loading && <span>{results.length} de 5</span>}
259
+ </div>
260
+ {!loading &&
261
+ results.map((product) => (
262
+ <Link href={productUrl(product)} key={product.slug}>
263
+ <span className="search-suggestion-image">
264
+ <Image image={product.image} fallbackAlt={product.title} />
265
+ </span>
266
+ <span className="search-suggestion-copy">
267
+ <strong>{product.title}</strong>
268
+ <small>
269
+ {product.sku
270
+ ? `Ref. ${product.sku}`
271
+ : product.categories[0]?.name || "Produto"}
272
+ </small>
273
+ </span>
274
+ {showPrices && displayPrice(product) && (
275
+ <b>{displayPrice(product)}</b>
276
+ )}
277
+ </Link>
278
+ ))}
279
+ {!loading && !results.length && (
280
+ <p>Nenhum produto próximo foi encontrado.</p>
281
+ )}
282
+ <Link
283
+ className="search-all-results"
284
+ href={`/produtos?busca=${encodeURIComponent(value.trim())}`}
285
+ >
286
+ Ver todos os resultados
287
+ </Link>
288
+ </div>
289
+ )}
290
+ </div>
291
+ );
177
292
  }
178
293
 
179
294
  function Header({ context, adapters }: Omit<DefaultThemeProps, "children">) {
@@ -182,7 +297,9 @@ function Header({ context, adapters }: Omit<DefaultThemeProps, "children">) {
182
297
  const name = settings?.siteName || context.store.name;
183
298
  const categories = context.navigation.categories;
184
299
  const extraLinks = moduleLinks(context);
185
- const configuredLinks = context.navigation.menu?.length ? context.navigation.menu : null;
300
+ const configuredLinks = context.navigation.menu?.length
301
+ ? context.navigation.menu
302
+ : null;
186
303
  const headerButton = context.navigation.headerButton;
187
304
 
188
305
  return (
@@ -197,21 +314,36 @@ function Header({ context, adapters }: Omit<DefaultThemeProps, "children">) {
197
314
  <div className="store-container header-inner">
198
315
  <Link className="brand" href="/">
199
316
  {settings?.logo?.url ? (
200
- <Image image={settings.logo} fallbackAlt={name} className="brand-logo" priority />
317
+ <Image
318
+ image={settings.logo}
319
+ fallbackAlt={name}
320
+ className="brand-logo"
321
+ priority
322
+ />
201
323
  ) : (
202
- <><span className="brand-mark">7</span><span>{name}</span></>
324
+ <>
325
+ <span className="brand-mark">7</span>
326
+ <span>{name}</span>
327
+ </>
203
328
  )}
204
329
  </Link>
205
330
  {context.site.modules.includes("PRODUCTS") && (
206
- <SmartSearch adapters={adapters} showPrices={settings?.catalog?.showPrices ?? true} />
331
+ <SmartSearch
332
+ adapters={adapters}
333
+ showPrices={settings?.catalog?.showPrices ?? true}
334
+ />
207
335
  )}
208
336
  <div className="header-message">
209
337
  <span className="header-message-icon" aria-hidden="true">
210
- <svg viewBox="0 0 24 24"><path d="m12 3 2.1 4.9L19 10l-4.9 2.1L12 17l-2.1-4.9L5 10l4.9-2.1L12 3Z" /></svg>
338
+ <svg viewBox="0 0 24 24">
339
+ <path d="m12 3 2.1 4.9L19 10l-4.9 2.1L12 17l-2.1-4.9L5 10l4.9-2.1L12 3Z" />
340
+ </svg>
211
341
  </span>
212
342
  <span className="header-message-copy">
213
343
  <small>Nossa loja</small>
214
- <strong>{settings?.description?.trim() || template.announcement}</strong>
344
+ <strong>
345
+ {settings?.description?.trim() || template.announcement}
346
+ </strong>
215
347
  </span>
216
348
  </div>
217
349
  {headerButton?.enabled && (
@@ -221,15 +353,28 @@ function Header({ context, adapters }: Omit<DefaultThemeProps, "children">) {
221
353
  rel={headerButton.openInNewTab ? "noreferrer" : undefined}
222
354
  target={headerButton.openInNewTab ? "_blank" : undefined}
223
355
  >
224
- <span style={{ backgroundColor: headerButton.backgroundColor, color: headerButton.textColor }}>{headerButton.label}</span>
356
+ <span
357
+ style={{
358
+ backgroundColor: headerButton.backgroundColor,
359
+ color: headerButton.textColor,
360
+ }}
361
+ >
362
+ {headerButton.label}
363
+ </span>
225
364
  </Link>
226
365
  )}
227
366
  {!configuredLinks && extraLinks.length > 0 && (
228
367
  <div className="header-actions">
229
368
  <details className="header-more-menu">
230
- <summary>Mais <span aria-hidden="true">⌄</span></summary>
369
+ <summary>
370
+ Mais <span aria-hidden="true">⌄</span>
371
+ </summary>
231
372
  <div className="header-more-panel">
232
- {extraLinks.map((item) => <Link href={item.href} key={item.href}>{item.label}</Link>)}
373
+ {extraLinks.map((item) => (
374
+ <Link href={item.href} key={item.href}>
375
+ {item.label}
376
+ </Link>
377
+ ))}
233
378
  </div>
234
379
  </details>
235
380
  </div>
@@ -237,9 +382,19 @@ function Header({ context, adapters }: Omit<DefaultThemeProps, "children">) {
237
382
  </div>
238
383
  {configuredLinks ? (
239
384
  <div className="primary-nav-shell">
240
- <nav className="store-container main-nav" aria-label="Navegação principal">
385
+ <nav
386
+ className="store-container main-nav"
387
+ aria-label="Navegação principal"
388
+ >
241
389
  {configuredLinks.map((item) => (
242
- <Link href={item.href} key={item.key} rel={item.openInNewTab ? "noreferrer" : undefined} target={item.openInNewTab ? "_blank" : undefined}>{item.label}</Link>
390
+ <Link
391
+ href={item.href}
392
+ key={item.key}
393
+ rel={item.openInNewTab ? "noreferrer" : undefined}
394
+ target={item.openInNewTab ? "_blank" : undefined}
395
+ >
396
+ {item.label}
397
+ </Link>
243
398
  ))}
244
399
  </nav>
245
400
  </div>
@@ -248,12 +403,17 @@ function Header({ context, adapters }: Omit<DefaultThemeProps, "children">) {
248
403
  <div className="store-container category-nav-inner">
249
404
  <details className="category-nav-all">
250
405
  <summary className="all-categories">
251
- <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16" /></svg>
406
+ <svg viewBox="0 0 24 24" aria-hidden="true">
407
+ <path d="M4 7h16M4 12h16M4 17h16" />
408
+ </svg>
252
409
  <span>Todas as categorias</span>
253
410
  </summary>
254
411
  <div className="category-nav-all-panel">
255
412
  <div className="category-nav-panel-heading">
256
- <div><span>Explore o catálogo</span><strong>Todas as categorias</strong></div>
413
+ <div>
414
+ <span>Explore o catálogo</span>
415
+ <strong>Todas as categorias</strong>
416
+ </div>
257
417
  <Link href="/produtos">Ver todos</Link>
258
418
  </div>
259
419
  <div className="category-nav-tree">
@@ -263,10 +423,16 @@ function Header({ context, adapters }: Omit<DefaultThemeProps, "children">) {
263
423
  </details>
264
424
  {categories.slice(0, 9).map((category) => (
265
425
  <div className="category-nav-group" key={category.slug}>
266
- <Link href={categoryUrl([category.slug])}>{category.name}</Link>
426
+ <Link href={categoryUrl([category.slug])}>
427
+ {category.name}
428
+ </Link>
267
429
  {category.children.length > 0 && (
268
430
  <div className="category-nav-submenu">
269
- <CategoryTree adapters={adapters} categories={category.children} path={[category.slug]} />
431
+ <CategoryTree
432
+ adapters={adapters}
433
+ categories={category.children}
434
+ path={[category.slug]}
435
+ />
270
436
  </div>
271
437
  )}
272
438
  </div>
@@ -275,10 +441,19 @@ function Header({ context, adapters }: Omit<DefaultThemeProps, "children">) {
275
441
  </nav>
276
442
  ) : (
277
443
  <div className="primary-nav-shell">
278
- <nav className="store-container main-nav" aria-label="Navegação principal">
444
+ <nav
445
+ className="store-container main-nav"
446
+ aria-label="Navegação principal"
447
+ >
279
448
  <Link href="/">Início</Link>
280
- {context.site.modules.includes("PRODUCTS") && <Link href="/produtos">Produtos</Link>}
281
- {extraLinks.map((item) => <Link href={item.href} key={item.href}>{item.label}</Link>)}
449
+ {context.site.modules.includes("PRODUCTS") && (
450
+ <Link href="/produtos">Produtos</Link>
451
+ )}
452
+ {extraLinks.map((item) => (
453
+ <Link href={item.href} key={item.href}>
454
+ {item.label}
455
+ </Link>
456
+ ))}
282
457
  </nav>
283
458
  </div>
284
459
  )}
@@ -287,7 +462,11 @@ function Header({ context, adapters }: Omit<DefaultThemeProps, "children">) {
287
462
  );
288
463
  }
289
464
 
290
- function ProductCard({ product, context, adapters }: {
465
+ function ProductCard({
466
+ product,
467
+ context,
468
+ adapters,
469
+ }: {
291
470
  product: ThemeProduct;
292
471
  context: ThemeContext;
293
472
  adapters: ThemeRuntimeAdapters;
@@ -302,15 +481,29 @@ function ProductCard({ product, context, adapters }: {
302
481
  </Link>
303
482
  <div className="product-card-content">
304
483
  {catalog.showCategory && (
305
- <span className={`product-category${product.categories[0] ? "" : " product-category-empty"}`}>
484
+ <span
485
+ className={`product-category${product.categories[0] ? "" : " product-category-empty"}`}
486
+ >
306
487
  {product.categories[0]?.name || "Sem categoria"}
307
488
  </span>
308
489
  )}
309
- <h3><Link href={href}>{product.title}</Link></h3>
490
+ <h3>
491
+ <Link href={href}>{product.title}</Link>
492
+ </h3>
310
493
  {catalog.showDescription && product.description && (
311
- <p className="product-card-description">{plainText(product.description)}</p>
494
+ <p className="product-card-description">
495
+ {plainText(product.description)}
496
+ </p>
497
+ )}
498
+ {catalog.showPrices && displayPrice(product) && (
499
+ <div className="product-card-price">
500
+ {originalPrice(product) && <s>De: {originalPrice(product)}</s>}
501
+ <b>
502
+ {originalPrice(product) ? "por " : ""}
503
+ {displayPrice(product)}
504
+ </b>
505
+ </div>
312
506
  )}
313
- {catalog.showPrices && displayPrice(product) && <div className="product-card-price">{originalPrice(product) && <s>De: {originalPrice(product)}</s>}<b>{originalPrice(product) ? "por " : ""}{displayPrice(product)}</b></div>}
314
507
  <Link className="button button-secondary button-block" href={href}>
315
508
  Ver detalhes e orçar
316
509
  </Link>
@@ -326,64 +519,161 @@ export interface ThemeSectionRendererProps {
326
519
  sdk?: ThemeRuntimeSdk;
327
520
  }
328
521
 
329
- export type ThemeSectionRenderer = (props: ThemeSectionRendererProps) => ReactNode;
330
- export type ThemeSectionRegistry = Partial<Record<ThemeHomeSectionType, ThemeSectionRenderer>>;
522
+ export type ThemeSectionRenderer = (
523
+ props: ThemeSectionRendererProps,
524
+ ) => ReactNode;
525
+ export type ThemeSectionRegistry = Partial<
526
+ Record<ThemeHomeSectionType, ThemeSectionRenderer>
527
+ >;
331
528
 
332
- function HeroSection({ section, context, adapters }: ThemeSectionRendererProps) {
529
+ function HeroSection({
530
+ section,
531
+ context,
532
+ adapters,
533
+ }: ThemeSectionRendererProps) {
333
534
  const { Link, Image } = adapters;
334
535
  const storeName = context.site.settings?.siteName || context.store.name;
335
536
  const eyebrow = dataString(section.data, "eyebrow", "Bem-vindo à nossa loja");
336
- const title = dataString(section.data, "title", "Tudo o que você procura, em um só lugar.");
337
- const description = dataString(section.data, "description", context.site.settings?.description || `Conheça a seleção de produtos da ${storeName}.`);
338
- const buttonLabel = dataString(section.data, "buttonLabel", "Explorar produtos");
537
+ const title = dataString(
538
+ section.data,
539
+ "title",
540
+ "Tudo o que você procura, em um só lugar.",
541
+ );
542
+ const description = dataString(
543
+ section.data,
544
+ "description",
545
+ context.site.settings?.description ||
546
+ `Conheça a seleção de produtos da ${storeName}.`,
547
+ );
548
+ const buttonLabel = dataString(
549
+ section.data,
550
+ "buttonLabel",
551
+ "Explorar produtos",
552
+ );
339
553
  const buttonUrl = dataString(section.data, "buttonUrl", "/produtos");
340
554
  const imageUrl = dataString(section.data, "imageUrl");
341
555
 
342
556
  if (imageUrl) {
343
557
  return (
344
558
  <section className="hero-section hero-section-image">
345
- <Image image={{ url: imageUrl, alt: dataString(section.data, "imageAlt", title), width: null, height: null }} fallbackAlt={title} className="hero-background-image" />
559
+ <Image
560
+ image={{
561
+ url: imageUrl,
562
+ alt: dataString(section.data, "imageAlt", title),
563
+ width: null,
564
+ height: null,
565
+ }}
566
+ fallbackAlt={title}
567
+ className="hero-background-image"
568
+ />
346
569
  <div className="hero-background-overlay" aria-hidden="true" />
347
- <div className="store-container hero-image-content"><div className="hero-copy">
348
- <span className="hero-eyebrow">{eyebrow}</span><h1>{title}</h1><p>{description}</p>
349
- <div className="hero-actions"><Link className="button button-primary" href={buttonUrl}>{buttonLabel}</Link><Link className="text-link" href="/produtos">Ver catálogo completo <span>→</span></Link></div>
350
- </div></div>
570
+ <div className="store-container hero-image-content">
571
+ <div className="hero-copy">
572
+ <span className="hero-eyebrow">{eyebrow}</span>
573
+ <h1>{title}</h1>
574
+ <p>{description}</p>
575
+ <div className="hero-actions">
576
+ <Link className="button button-primary" href={buttonUrl}>
577
+ {buttonLabel}
578
+ </Link>
579
+ <Link className="text-link" href="/produtos">
580
+ Ver catálogo completo <span>→</span>
581
+ </Link>
582
+ </div>
583
+ </div>
584
+ </div>
351
585
  </section>
352
586
  );
353
587
  }
354
588
 
355
589
  return (
356
- <section className="hero-section"><div className="store-container hero-grid">
357
- <div className="hero-copy">
358
- <span className="hero-eyebrow">{eyebrow}</span><h1>{title}</h1><p>{description}</p>
359
- <div className="hero-actions"><Link className="button button-primary" href={buttonUrl}>{buttonLabel}</Link><Link className="text-link" href="/produtos">Ver catálogo completo <span>→</span></Link></div>
590
+ <section className="hero-section">
591
+ <div className="store-container hero-grid">
592
+ <div className="hero-copy">
593
+ <span className="hero-eyebrow">{eyebrow}</span>
594
+ <h1>{title}</h1>
595
+ <p>{description}</p>
596
+ <div className="hero-actions">
597
+ <Link className="button button-primary" href={buttonUrl}>
598
+ {buttonLabel}
599
+ </Link>
600
+ <Link className="text-link" href="/produtos">
601
+ Ver catálogo completo <span>→</span>
602
+ </Link>
603
+ </div>
604
+ </div>
605
+ <div className="hero-art" aria-hidden="true">
606
+ <div className="hero-orbit hero-orbit-one" />
607
+ <div className="hero-orbit hero-orbit-two" />
608
+ <div className="hero-seven">7</div>
609
+ <span className="hero-card hero-card-top">Seleção especial</span>
610
+ <span className="hero-card hero-card-bottom">Atendimento humano</span>
611
+ </div>
360
612
  </div>
361
- <div className="hero-art" aria-hidden="true"><div className="hero-orbit hero-orbit-one" /><div className="hero-orbit hero-orbit-two" /><div className="hero-seven">7</div><span className="hero-card hero-card-top">Seleção especial</span><span className="hero-card hero-card-bottom">Atendimento humano</span></div>
362
- </div></section>
613
+ </section>
363
614
  );
364
615
  }
365
616
 
366
617
  function BannerSection({ section, adapters }: ThemeSectionRendererProps) {
367
618
  const { Link } = adapters;
368
619
  const data = section.data as ThemeBannerCarouselData;
369
- const banner = data.banners?.find((item) => Boolean(item.image?.url || item.imageUrl));
620
+ const banner = data.banners?.find((item) =>
621
+ Boolean(item.image?.url || item.imageUrl),
622
+ );
370
623
  const desktopUrl = banner?.image?.url || banner?.imageUrl || "";
371
624
  const mobileUrl = banner?.mobileImage?.url || banner?.mobileImageUrl || "";
372
625
  if (!banner || !desktopUrl) return null;
373
626
  const natural = data.imageFit === "NATURAL";
374
627
  const fit = data.imageFit === "CONTAIN" ? "contain" : "cover";
375
628
  return (
376
- <section className="banner-carousel" data-image-fit={data.imageFit || "COVER"} style={{ "--banner-desktop-height": `${data.desktopHeight || 520}px`, "--banner-mobile-height": `${data.mobileHeight || 360}px` } as CSSProperties}><div className="banner-track"><article className="banner-slide">
377
- <picture className="banner-responsive-media">
378
- {mobileUrl && <source media="(max-width: 700px)" srcSet={mobileUrl} />}
379
- <img src={desktopUrl} alt={banner.imageAlt || banner.image?.alt || banner.title || "Banner"} style={{ display: "block", height: natural ? "auto" : "100%", objectFit: fit, width: "100%" }} />
380
- </picture>
381
- <div className="banner-overlay"><div className="store-container"><div className="banner-copy">
382
- {banner.title && <h2>{banner.title}</h2>}
383
- {banner.description && <p>{banner.description}</p>}
384
- {banner.buttonLabel && banner.buttonUrl && <Link className="button button-primary" href={banner.buttonUrl}>{banner.buttonLabel}</Link>}
385
- </div></div></div>
386
- </article></div></section>
629
+ <section
630
+ className="banner-carousel"
631
+ data-image-fit={data.imageFit || "COVER"}
632
+ style={
633
+ {
634
+ "--banner-desktop-height": `${data.desktopHeight || 520}px`,
635
+ "--banner-mobile-height": `${data.mobileHeight || 360}px`,
636
+ } as CSSProperties
637
+ }
638
+ >
639
+ <div className="banner-track">
640
+ <article className="banner-slide">
641
+ <picture className="banner-responsive-media">
642
+ {mobileUrl && (
643
+ <source media="(max-width: 700px)" srcSet={mobileUrl} />
644
+ )}
645
+ <img
646
+ src={desktopUrl}
647
+ alt={
648
+ banner.imageAlt || banner.image?.alt || banner.title || "Banner"
649
+ }
650
+ style={{
651
+ display: "block",
652
+ height: natural ? "auto" : "100%",
653
+ objectFit: fit,
654
+ width: "100%",
655
+ }}
656
+ />
657
+ </picture>
658
+ <div className="banner-overlay">
659
+ <div className="store-container">
660
+ <div className="banner-copy">
661
+ {banner.title && <h2>{banner.title}</h2>}
662
+ {banner.description && <p>{banner.description}</p>}
663
+ {banner.buttonLabel && banner.buttonUrl && (
664
+ <Link
665
+ className="button button-primary"
666
+ href={banner.buttonUrl}
667
+ >
668
+ {banner.buttonLabel}
669
+ </Link>
670
+ )}
671
+ </div>
672
+ </div>
673
+ </div>
674
+ </article>
675
+ </div>
676
+ </section>
387
677
  );
388
678
  }
389
679
 
@@ -396,14 +686,46 @@ function MiniBannersSection({ section, adapters }: ThemeSectionRendererProps) {
396
686
  if (!items.length) return null;
397
687
  return (
398
688
  <section className="store-section mini-banners-section">
399
- <div className="store-container mini-banners-grid" data-layout={data.layout}>
689
+ <div
690
+ className="store-container mini-banners-grid"
691
+ data-layout={data.layout}
692
+ >
400
693
  {items.map((item, index) => {
401
- const image = item.image || (item.imageUrl ? { url: item.imageUrl, alt: item.imageAlt || item.title || "Mini banner", width: null, height: null } : null);
694
+ const image =
695
+ item.image ||
696
+ (item.imageUrl
697
+ ? {
698
+ url: item.imageUrl,
699
+ alt: item.imageAlt || item.title || "Mini banner",
700
+ width: null,
701
+ height: null,
702
+ }
703
+ : null);
402
704
  if (!image) return null;
403
- const content = <><span className="mini-banner-image"><Image image={image} fallbackAlt={item.title || "Mini banner"} /></span>{item.title && <strong>{item.title}</strong>}</>;
404
- return item.link
405
- ? <Link className="mini-banner-card" href={item.link} key={`${image.url}-${index}`}>{content}</Link>
406
- : <div className="mini-banner-card" key={`${image.url}-${index}`}>{content}</div>;
705
+ const content = (
706
+ <>
707
+ <span className="mini-banner-image">
708
+ <Image
709
+ image={image}
710
+ fallbackAlt={item.title || "Mini banner"}
711
+ />
712
+ </span>
713
+ {item.title && <strong>{item.title}</strong>}
714
+ </>
715
+ );
716
+ return item.link ? (
717
+ <Link
718
+ className="mini-banner-card"
719
+ href={item.link}
720
+ key={`${image.url}-${index}`}
721
+ >
722
+ {content}
723
+ </Link>
724
+ ) : (
725
+ <div className="mini-banner-card" key={`${image.url}-${index}`}>
726
+ {content}
727
+ </div>
728
+ );
407
729
  })}
408
730
  </div>
409
731
  </section>
@@ -414,40 +736,93 @@ function TextSection({ section, adapters }: ThemeSectionRendererProps) {
414
736
  const { Link, Image } = adapters;
415
737
  const title = dataString(section.data, "title", "Conteúdo");
416
738
  const eyebrow = dataString(section.data, "eyebrow");
417
- const description = dataString(section.data, "description", dataString(section.data, "text"));
739
+ const description = dataString(
740
+ section.data,
741
+ "description",
742
+ dataString(section.data, "text"),
743
+ );
418
744
  const imageUrl = dataString(section.data, "imageUrl");
419
- if (!description && !imageUrl && !dataString(section.data, "title")) return null;
745
+ if (!description && !imageUrl && !dataString(section.data, "title"))
746
+ return null;
420
747
 
421
748
  if (section.type === "image-text") {
422
- return <section className="store-section image-text-section"><div className="store-container image-text-layout" data-position={section.data.imagePosition === "right" ? "right" : "left"}>
423
- {imageUrl && <div className="image-text-media"><Image image={{ url: imageUrl, alt: title, width: null, height: null }} fallbackAlt={title} /></div>}
424
- <div className="image-text-copy">{eyebrow && <span>{eyebrow}</span>}<h2>{title}</h2>{description && <p>{description}</p>}</div>
425
- </div></section>;
749
+ return (
750
+ <section className="store-section image-text-section">
751
+ <div
752
+ className="store-container image-text-layout"
753
+ data-position={
754
+ section.data.imagePosition === "right" ? "right" : "left"
755
+ }
756
+ >
757
+ {imageUrl && (
758
+ <div className="image-text-media">
759
+ <Image
760
+ image={{ url: imageUrl, alt: title, width: null, height: null }}
761
+ fallbackAlt={title}
762
+ />
763
+ </div>
764
+ )}
765
+ <div className="image-text-copy">
766
+ {eyebrow && <span>{eyebrow}</span>}
767
+ <h2>{title}</h2>
768
+ {description && <p>{description}</p>}
769
+ </div>
770
+ </div>
771
+ </section>
772
+ );
426
773
  }
427
774
 
428
- return <section className="store-section editorial-section"><div className="store-container editorial-content">
429
- {eyebrow && <span>{eyebrow}</span>}<h2>{title}</h2>{description && <p>{description}</p>}
430
- {section.type === "cta" && dataString(section.data, "buttonLabel") && dataString(section.data, "buttonUrl") && <Link className="button button-primary" href={dataString(section.data, "buttonUrl")}>{dataString(section.data, "buttonLabel")}</Link>}
431
- </div></section>;
775
+ return (
776
+ <section className="store-section editorial-section">
777
+ <div className="store-container editorial-content">
778
+ {eyebrow && <span>{eyebrow}</span>}
779
+ <h2>{title}</h2>
780
+ {description && <p>{description}</p>}
781
+ {section.type === "cta" &&
782
+ dataString(section.data, "buttonLabel") &&
783
+ dataString(section.data, "buttonUrl") && (
784
+ <Link
785
+ className="button button-primary"
786
+ href={dataString(section.data, "buttonUrl")}
787
+ >
788
+ {dataString(section.data, "buttonLabel")}
789
+ </Link>
790
+ )}
791
+ </div>
792
+ </section>
793
+ );
432
794
  }
433
795
 
434
- function dataRecord(data: Record<string, unknown>, field: string): Record<string, unknown> {
796
+ function dataRecord(
797
+ data: Record<string, unknown>,
798
+ field: string,
799
+ ): Record<string, unknown> {
435
800
  const value = data[field];
436
801
  return value && typeof value === "object" && !Array.isArray(value)
437
- ? value as Record<string, unknown>
802
+ ? (value as Record<string, unknown>)
438
803
  : {};
439
804
  }
440
805
 
441
- function dataRecords(data: Record<string, unknown>, field: string): Record<string, unknown>[] {
806
+ function dataRecords(
807
+ data: Record<string, unknown>,
808
+ field: string,
809
+ ): Record<string, unknown>[] {
442
810
  const value = data[field];
443
811
  return Array.isArray(value)
444
- ? value.filter((item): item is Record<string, unknown> => Boolean(item) && typeof item === "object" && !Array.isArray(item))
812
+ ? value.filter(
813
+ (item): item is Record<string, unknown> =>
814
+ Boolean(item) && typeof item === "object" && !Array.isArray(item),
815
+ )
445
816
  : [];
446
817
  }
447
818
 
448
819
  function formatWhatsapp(value: string): string {
449
820
  const rawDigits = value.replace(/\D/g, "");
450
- const digits = (rawDigits.length > 11 && rawDigits.startsWith("55") ? rawDigits.slice(2) : rawDigits).slice(0, 11);
821
+ const digits = (
822
+ rawDigits.length > 11 && rawDigits.startsWith("55")
823
+ ? rawDigits.slice(2)
824
+ : rawDigits
825
+ ).slice(0, 11);
451
826
  if (!digits) return "";
452
827
  if (digits.length <= 2) return `(${digits}`;
453
828
  const number = digits.slice(2);
@@ -459,22 +834,40 @@ function formatWhatsapp(value: string): string {
459
834
 
460
835
  function formatCep(value: string): string {
461
836
  const digits = value.replace(/\D/g, "").slice(0, 8);
462
- return digits.length > 5 ? `${digits.slice(0, 5)}-${digits.slice(5)}` : digits;
837
+ return digits.length > 5
838
+ ? `${digits.slice(0, 5)}-${digits.slice(5)}`
839
+ : digits;
463
840
  }
464
841
 
465
842
  function formatDocument(value: string, mask: string): string {
466
843
  if (mask === "rg-br") {
467
- const chars = value.toUpperCase().replace(/[^0-9X]/g, "").slice(0, 9);
468
- return chars.replace(/^(\d{2})(\d{1,3})?(\d{1,3})?([0-9X])?$/, (_, a: string, b?: string, c?: string, d?: string) =>
469
- [a, b, c].filter(Boolean).join(".") + (d ? `-${d}` : ""));
844
+ const chars = value
845
+ .toUpperCase()
846
+ .replace(/[^0-9X]/g, "")
847
+ .slice(0, 9);
848
+ return chars.replace(
849
+ /^(\d{2})(\d{1,3})?(\d{1,3})?([0-9X])?$/,
850
+ (_, a: string, b?: string, c?: string, d?: string) =>
851
+ [a, b, c].filter(Boolean).join(".") + (d ? `-${d}` : ""),
852
+ );
470
853
  }
471
854
  const digits = value.replace(/\D/g, "").slice(0, mask === "cpf-br" ? 11 : 14);
472
- if (mask === "cpf-br" || mask === "cpf-cnpj-br" && digits.length <= 11) {
473
- return digits.replace(/^(\d{3})(\d{1,3})?(\d{1,3})?(\d{1,2})?$/, (_, a: string, b?: string, c?: string, d?: string) =>
474
- a + (b ? `.${b}` : "") + (c ? `.${c}` : "") + (d ? `-${d}` : ""));
855
+ if (mask === "cpf-br" || (mask === "cpf-cnpj-br" && digits.length <= 11)) {
856
+ return digits.replace(
857
+ /^(\d{3})(\d{1,3})?(\d{1,3})?(\d{1,2})?$/,
858
+ (_, a: string, b?: string, c?: string, d?: string) =>
859
+ a + (b ? `.${b}` : "") + (c ? `.${c}` : "") + (d ? `-${d}` : ""),
860
+ );
475
861
  }
476
- return digits.replace(/^(\d{2})(\d{1,3})?(\d{1,3})?(\d{1,4})?(\d{1,2})?$/, (_, a: string, b?: string, c?: string, d?: string, e?: string) =>
477
- a + (b ? `.${b}` : "") + (c ? `.${c}` : "") + (d ? `/${d}` : "") + (e ? `-${e}` : ""));
862
+ return digits.replace(
863
+ /^(\d{2})(\d{1,3})?(\d{1,3})?(\d{1,4})?(\d{1,2})?$/,
864
+ (_, a: string, b?: string, c?: string, d?: string, e?: string) =>
865
+ a +
866
+ (b ? `.${b}` : "") +
867
+ (c ? `.${c}` : "") +
868
+ (d ? `/${d}` : "") +
869
+ (e ? `-${e}` : ""),
870
+ );
478
871
  }
479
872
 
480
873
  const addressFieldAliases = {
@@ -488,18 +881,25 @@ function ContactFormComponent({ section, sdk }: ThemeSectionRendererProps) {
488
881
  const props = dataRecord(section.data, "props");
489
882
  const configuredFields = dataRecords(props, "fields");
490
883
  const fields = configuredFields;
491
- const [status, setStatus] = useState<"idle" | "sending" | "success" | "error">("idle");
884
+ const [status, setStatus] = useState<
885
+ "idle" | "sending" | "success" | "error"
886
+ >("idle");
492
887
  const [error, setError] = useState("");
493
- const [cepStatus, setCepStatus] = useState<"idle" | "loading" | "success" | "error">("idle");
888
+ const [cepStatus, setCepStatus] = useState<
889
+ "idle" | "loading" | "success" | "error"
890
+ >("idle");
494
891
  const [cepMessage, setCepMessage] = useState("");
495
892
  const formRef = useRef<HTMLFormElement>(null);
496
893
  const lastSearchedCep = useRef("");
497
894
  const cepController = useRef<AbortController | null>(null);
498
895
 
499
- useEffect(() => () => {
500
- cepController.current?.abort();
501
- cepController.current = null;
502
- }, []);
896
+ useEffect(
897
+ () => () => {
898
+ cepController.current?.abort();
899
+ cepController.current = null;
900
+ },
901
+ [],
902
+ );
503
903
 
504
904
  const searchCep = async (value: string) => {
505
905
  const cleanCep = value.replace(/\D/g, "");
@@ -522,14 +922,25 @@ function ContactFormComponent({ section, sdk }: ThemeSectionRendererProps) {
522
922
  setCepMessage("Buscando endereço…");
523
923
 
524
924
  try {
525
- const response = await fetch(`https://viacep.com.br/ws/${cleanCep}/json/`, {
526
- signal: controller.signal,
527
- });
925
+ const response = await fetch(
926
+ `https://viacep.com.br/ws/${cleanCep}/json/`,
927
+ {
928
+ signal: controller.signal,
929
+ },
930
+ );
528
931
  if (!response.ok) throw new Error("CEP_FETCH_FAILED");
529
- const data = await response.json() as { erro?: boolean; logradouro?: string; bairro?: string; localidade?: string; uf?: string };
932
+ const data = (await response.json()) as {
933
+ erro?: boolean;
934
+ logradouro?: string;
935
+ bairro?: string;
936
+ localidade?: string;
937
+ uf?: string;
938
+ };
530
939
  if (data.erro) {
531
940
  setCepStatus("error");
532
- setCepMessage("CEP não encontrado. Confira o número ou preencha o endereço manualmente.");
941
+ setCepMessage(
942
+ "CEP não encontrado. Confira o número ou preencha o endereço manualmente.",
943
+ );
533
944
  return;
534
945
  }
535
946
 
@@ -539,23 +950,31 @@ function ContactFormComponent({ section, sdk }: ThemeSectionRendererProps) {
539
950
  city: data.localidade || "",
540
951
  state: data.uf || "",
541
952
  };
542
- const configuredKeys = new Set(fields.map((field) => dataString(field, "key")));
953
+ const configuredKeys = new Set(
954
+ fields.map((field) => dataString(field, "key")),
955
+ );
543
956
  for (const [part, aliases] of Object.entries(addressFieldAliases)) {
544
957
  const targetKey = aliases.find((alias) => configuredKeys.has(alias));
545
958
  const nextValue = addressValues[part as keyof typeof addressValues];
546
959
  const target = targetKey
547
960
  ? formRef.current?.elements.namedItem(targetKey)
548
961
  : null;
549
- if (nextValue && target instanceof HTMLInputElement) target.value = nextValue;
962
+ if (nextValue && target instanceof HTMLInputElement)
963
+ target.value = nextValue;
550
964
  }
551
965
  setCepStatus("success");
552
- setCepMessage("Endereço preenchido. Confira os dados e informe o número, se necessário.");
966
+ setCepMessage(
967
+ "Endereço preenchido. Confira os dados e informe o número, se necessário.",
968
+ );
553
969
  } catch {
554
- if (controller.signal.aborted && cepController.current !== controller) return;
970
+ if (controller.signal.aborted && cepController.current !== controller)
971
+ return;
555
972
  setCepStatus("error");
556
- setCepMessage(controller.signal.aborted
557
- ? "A consulta demorou demais. Você pode preencher o endereço manualmente."
558
- : "Não foi possível consultar o CEP. Preencha o endereço manualmente.");
973
+ setCepMessage(
974
+ controller.signal.aborted
975
+ ? "A consulta demorou demais. Você pode preencher o endereço manualmente."
976
+ : "Não foi possível consultar o CEP. Preencha o endereço manualmente.",
977
+ );
559
978
  } finally {
560
979
  window.clearTimeout(timeout);
561
980
  }
@@ -586,7 +1005,7 @@ function ContactFormComponent({ section, sdk }: ThemeSectionRendererProps) {
586
1005
  continue;
587
1006
  }
588
1007
  const all = form.getAll(key).map(String);
589
- values[key] = all.length > 1 ? all : all[0] ?? "";
1008
+ values[key] = all.length > 1 ? all : (all[0] ?? "");
590
1009
  }
591
1010
  try {
592
1011
  await sdk.contact.submit({
@@ -594,7 +1013,8 @@ function ContactFormComponent({ section, sdk }: ThemeSectionRendererProps) {
594
1013
  sectionId: section.id,
595
1014
  values,
596
1015
  ...(Object.keys(attachments).length ? { attachments } : {}),
597
- pathname: typeof window === "undefined" ? undefined : window.location.pathname,
1016
+ pathname:
1017
+ typeof window === "undefined" ? undefined : window.location.pathname,
598
1018
  });
599
1019
  event.currentTarget.reset();
600
1020
  lastSearchedCep.current = "";
@@ -603,148 +1023,552 @@ function ContactFormComponent({ section, sdk }: ThemeSectionRendererProps) {
603
1023
  setStatus("success");
604
1024
  } catch (cause) {
605
1025
  setStatus("error");
606
- setError(cause instanceof Error ? cause.message : "Não foi possível enviar o contato.");
1026
+ setError(
1027
+ cause instanceof Error
1028
+ ? cause.message
1029
+ : "Não foi possível enviar o contato.",
1030
+ );
607
1031
  }
608
1032
  };
609
1033
 
610
- return <section className="store-section theme-component-section contact-form-section"><div className="store-container contact-form-layout">
611
- <div className="contact-form-copy">
612
- {dataString(props, "eyebrow") && <span>{dataString(props, "eyebrow")}</span>}
613
- <h2>{dataString(props, "title", "Fale com nossa equipe")}</h2>
614
- {dataString(props, "description") && <p>{dataString(props, "description")}</p>}
615
- </div>
616
- <form className="contact-form" ref={formRef} onSubmit={(event) => void submit(event)}>
617
- {fields.map((field) => {
618
- const key = dataString(field, "key");
619
- if (!key) return null;
620
- const type = dataString(field, "type", "text");
621
- const label = dataString(field, "label", key);
622
- const required = field.required === true;
623
- if (type === "checkbox") return <label className="contact-form-wide contact-form-checkbox" key={key}>
624
- <input name={key} required={required} type="checkbox" value="true" />
625
- <span>{label}{required && <small aria-hidden="true"> *</small>}</span>
626
- </label>;
627
- if (type === "file") return <label className="contact-form-wide" key={key}>
628
- <span>{label}{required && <small aria-hidden="true"> *</small>}</span>
629
- <input name={key} required={required} type="file" accept=".pdf,.jpg,.jpeg,.png,application/pdf,image/jpeg,image/png" />
630
- <small>PDF, JPG ou PNG, até 4 MB no total.</small>
631
- </label>;
632
- if (type === "select") return <label key={key}>
633
- <span>{label}{required && <small aria-hidden="true"> *</small>}</span>
634
- <select name={key} required={required}>{dataRecords(field, "options").map((option) => <option key={dataString(option, "value")} value={dataString(option, "value")}>{dataString(option, "label", dataString(option, "value"))}</option>)}</select>
635
- </label>;
636
- return <label className={type === "textarea" ? "contact-form-wide" : ""} key={key}>
637
- <span>{label}{required && <small aria-hidden="true"> *</small>}</span>
638
- {type === "textarea"
639
- ? <textarea name={key} placeholder={dataString(field, "placeholder")} required={required} rows={5} />
640
- : <input
641
- name={key}
642
- placeholder={dataString(field, "placeholder")}
643
- required={required}
644
- type={["email", "tel", "url", "number"].includes(type) ? type : "text"}
645
- maxLength={dataString(field, "mask") === "cep-br" ? 9 : dataString(field, "mask") === "cpf-br" ? 14 : dataString(field, "mask") === "cnpj-br" || dataString(field, "mask") === "cpf-cnpj-br" ? 18 : dataString(field, "mask") === "rg-br" ? 12 : undefined}
646
- inputMode={["cep-br", "cpf-br", "cnpj-br", "cpf-cnpj-br"].includes(dataString(field, "mask")) ? "numeric" : undefined}
647
- autoComplete={dataString(field, "mask") === "cep-br" ? "postal-code" : undefined}
648
- pattern={dataString(field, "mask") === "whatsapp-br" ? "\\([1-9][0-9]\\) [0-9]{4,5}-[0-9]{4}" : undefined}
649
- title={dataString(field, "mask") === "whatsapp-br" ? "Informe o DDD e um telefone com 8 ou 9 dígitos." : undefined}
650
- onInput={dataString(field, "mask") === "whatsapp-br" ? (event) => { event.currentTarget.value = formatWhatsapp(event.currentTarget.value); } : dataString(field, "mask") === "cep-br" ? (event) => { event.currentTarget.value = formatCep(event.currentTarget.value); void searchCep(event.currentTarget.value); } : ["cpf-br", "cnpj-br", "cpf-cnpj-br", "rg-br"].includes(dataString(field, "mask")) ? (event) => { event.currentTarget.value = formatDocument(event.currentTarget.value, dataString(field, "mask")); } : undefined}
651
- />}
652
- </label>;
653
- })}
654
- <div className="contact-form-wide">
655
- {cepStatus !== "idle" && <p className={`contact-form-feedback${cepStatus === "error" ? " contact-form-error" : ""}`} role={cepStatus === "error" ? "alert" : "status"}>{cepMessage}</p>}
656
- <button className="button button-primary" disabled={status === "sending"} type="submit">
657
- {status === "sending" ? "Enviando…" : dataString(props, "submitLabel", "Enviar contato")}
658
- </button>
659
- {status === "success" && <p className="contact-form-feedback" role="status">{dataString(props, "successMessage", "Contato enviado com sucesso.")}</p>}
660
- {status === "error" && <p className="contact-form-feedback contact-form-error" role="alert">{error}</p>}
1034
+ return (
1035
+ <section className="store-section theme-component-section contact-form-section">
1036
+ <div className="store-container contact-form-layout">
1037
+ <div className="contact-form-copy">
1038
+ {dataString(props, "eyebrow") && (
1039
+ <span>{dataString(props, "eyebrow")}</span>
1040
+ )}
1041
+ <h2>{dataString(props, "title", "Fale com nossa equipe")}</h2>
1042
+ {dataString(props, "description") && (
1043
+ <p>{dataString(props, "description")}</p>
1044
+ )}
1045
+ </div>
1046
+ <form
1047
+ className="contact-form"
1048
+ ref={formRef}
1049
+ onSubmit={(event) => void submit(event)}
1050
+ >
1051
+ {fields.map((field) => {
1052
+ const key = dataString(field, "key");
1053
+ if (!key) return null;
1054
+ const type = dataString(field, "type", "text");
1055
+ const label = dataString(field, "label", key);
1056
+ const required = field.required === true;
1057
+ if (type === "checkbox")
1058
+ return (
1059
+ <label
1060
+ className="contact-form-wide contact-form-checkbox"
1061
+ key={key}
1062
+ >
1063
+ <input
1064
+ name={key}
1065
+ required={required}
1066
+ type="checkbox"
1067
+ value="true"
1068
+ />
1069
+ <span>
1070
+ {label}
1071
+ {required && <small aria-hidden="true"> *</small>}
1072
+ </span>
1073
+ </label>
1074
+ );
1075
+ if (type === "file")
1076
+ return (
1077
+ <label className="contact-form-wide" key={key}>
1078
+ <span>
1079
+ {label}
1080
+ {required && <small aria-hidden="true"> *</small>}
1081
+ </span>
1082
+ <input
1083
+ name={key}
1084
+ required={required}
1085
+ type="file"
1086
+ accept=".pdf,.jpg,.jpeg,.png,application/pdf,image/jpeg,image/png"
1087
+ />
1088
+ <small>PDF, JPG ou PNG, até 4 MB no total.</small>
1089
+ </label>
1090
+ );
1091
+ if (type === "select")
1092
+ return (
1093
+ <label key={key}>
1094
+ <span>
1095
+ {label}
1096
+ {required && <small aria-hidden="true"> *</small>}
1097
+ </span>
1098
+ <select name={key} required={required}>
1099
+ {dataRecords(field, "options").map((option) => (
1100
+ <option
1101
+ key={dataString(option, "value")}
1102
+ value={dataString(option, "value")}
1103
+ >
1104
+ {dataString(
1105
+ option,
1106
+ "label",
1107
+ dataString(option, "value"),
1108
+ )}
1109
+ </option>
1110
+ ))}
1111
+ </select>
1112
+ </label>
1113
+ );
1114
+ return (
1115
+ <label
1116
+ className={type === "textarea" ? "contact-form-wide" : ""}
1117
+ key={key}
1118
+ >
1119
+ <span>
1120
+ {label}
1121
+ {required && <small aria-hidden="true"> *</small>}
1122
+ </span>
1123
+ {type === "textarea" ? (
1124
+ <textarea
1125
+ name={key}
1126
+ placeholder={dataString(field, "placeholder")}
1127
+ required={required}
1128
+ rows={5}
1129
+ />
1130
+ ) : (
1131
+ <input
1132
+ name={key}
1133
+ placeholder={dataString(field, "placeholder")}
1134
+ required={required}
1135
+ type={
1136
+ ["email", "tel", "url", "number"].includes(type)
1137
+ ? type
1138
+ : "text"
1139
+ }
1140
+ maxLength={
1141
+ dataString(field, "mask") === "cep-br"
1142
+ ? 9
1143
+ : dataString(field, "mask") === "cpf-br"
1144
+ ? 14
1145
+ : dataString(field, "mask") === "cnpj-br" ||
1146
+ dataString(field, "mask") === "cpf-cnpj-br"
1147
+ ? 18
1148
+ : dataString(field, "mask") === "rg-br"
1149
+ ? 12
1150
+ : undefined
1151
+ }
1152
+ inputMode={
1153
+ ["cep-br", "cpf-br", "cnpj-br", "cpf-cnpj-br"].includes(
1154
+ dataString(field, "mask"),
1155
+ )
1156
+ ? "numeric"
1157
+ : undefined
1158
+ }
1159
+ autoComplete={
1160
+ dataString(field, "mask") === "cep-br"
1161
+ ? "postal-code"
1162
+ : undefined
1163
+ }
1164
+ pattern={
1165
+ dataString(field, "mask") === "whatsapp-br"
1166
+ ? "\\([1-9][0-9]\\) [0-9]{4,5}-[0-9]{4}"
1167
+ : undefined
1168
+ }
1169
+ title={
1170
+ dataString(field, "mask") === "whatsapp-br"
1171
+ ? "Informe o DDD e um telefone com 8 ou 9 dígitos."
1172
+ : undefined
1173
+ }
1174
+ onInput={
1175
+ dataString(field, "mask") === "whatsapp-br"
1176
+ ? (event) => {
1177
+ event.currentTarget.value = formatWhatsapp(
1178
+ event.currentTarget.value,
1179
+ );
1180
+ }
1181
+ : dataString(field, "mask") === "cep-br"
1182
+ ? (event) => {
1183
+ event.currentTarget.value = formatCep(
1184
+ event.currentTarget.value,
1185
+ );
1186
+ void searchCep(event.currentTarget.value);
1187
+ }
1188
+ : [
1189
+ "cpf-br",
1190
+ "cnpj-br",
1191
+ "cpf-cnpj-br",
1192
+ "rg-br",
1193
+ ].includes(dataString(field, "mask"))
1194
+ ? (event) => {
1195
+ event.currentTarget.value = formatDocument(
1196
+ event.currentTarget.value,
1197
+ dataString(field, "mask"),
1198
+ );
1199
+ }
1200
+ : undefined
1201
+ }
1202
+ />
1203
+ )}
1204
+ </label>
1205
+ );
1206
+ })}
1207
+ <div className="contact-form-wide">
1208
+ {cepStatus !== "idle" && (
1209
+ <p
1210
+ className={`contact-form-feedback${cepStatus === "error" ? " contact-form-error" : ""}`}
1211
+ role={cepStatus === "error" ? "alert" : "status"}
1212
+ >
1213
+ {cepMessage}
1214
+ </p>
1215
+ )}
1216
+ <button
1217
+ className="button button-primary"
1218
+ disabled={status === "sending"}
1219
+ type="submit"
1220
+ >
1221
+ {status === "sending"
1222
+ ? "Enviando…"
1223
+ : dataString(props, "submitLabel", "Enviar contato")}
1224
+ </button>
1225
+ {status === "success" && (
1226
+ <p className="contact-form-feedback" role="status">
1227
+ {dataString(
1228
+ props,
1229
+ "successMessage",
1230
+ "Contato enviado com sucesso.",
1231
+ )}
1232
+ </p>
1233
+ )}
1234
+ {status === "error" && (
1235
+ <p
1236
+ className="contact-form-feedback contact-form-error"
1237
+ role="alert"
1238
+ >
1239
+ {error}
1240
+ </p>
1241
+ )}
1242
+ </div>
1243
+ </form>
661
1244
  </div>
662
- </form>
663
- </div></section>;
1245
+ </section>
1246
+ );
664
1247
  }
665
1248
 
666
- function PageContent({ route, context, adapters, sdk }: {
1249
+ function PageContent({
1250
+ route,
1251
+ context,
1252
+ adapters,
1253
+ sdk,
1254
+ }: {
667
1255
  route: Extract<ThemeRoute, { type: "page" }>;
668
1256
  context: ThemeContext;
669
1257
  adapters: ThemeRuntimeAdapters;
670
1258
  sdk?: ThemeRuntimeSdk;
671
1259
  }) {
672
- return <main className="store-section"><article className="store-container editorial-content">
673
- <h1>{route.title}</h1>
674
- {route.content.blocks.map((block, index) => {
675
- if (block.type === "theme-component") return <ThemeComponentSection key={block.id || index} section={{ id: block.id, type: "theme-component", enabled: true, order: index, data: block.data }} context={context} adapters={adapters} sdk={sdk} />;
676
- if (block.type === "header") return <h2 key={block.id || index}>{plainText(dataString(block.data, "text"))}</h2>;
677
- if (block.type === "paragraph") return <p key={block.id || index}>{plainText(dataString(block.data, "text"))}</p>;
678
- if (block.type === "delimiter") return <hr key={block.id || index} />;
679
- return null;
680
- })}
681
- </article></main>;
1260
+ return (
1261
+ <main className="store-section">
1262
+ <article className="store-container editorial-content">
1263
+ <h1>{route.title}</h1>
1264
+ {route.content.blocks.map((block, index) => {
1265
+ if (block.type === "theme-component")
1266
+ return (
1267
+ <ThemeComponentSection
1268
+ key={block.id || index}
1269
+ section={{
1270
+ id: block.id,
1271
+ type: "theme-component",
1272
+ enabled: true,
1273
+ order: index,
1274
+ data: block.data,
1275
+ }}
1276
+ context={context}
1277
+ adapters={adapters}
1278
+ sdk={sdk}
1279
+ />
1280
+ );
1281
+ if (block.type === "header")
1282
+ return (
1283
+ <h2 key={block.id || index}>
1284
+ {plainText(dataString(block.data, "text"))}
1285
+ </h2>
1286
+ );
1287
+ if (block.type === "paragraph")
1288
+ return (
1289
+ <p key={block.id || index}>
1290
+ {plainText(dataString(block.data, "text"))}
1291
+ </p>
1292
+ );
1293
+ if (block.type === "delimiter") return <hr key={block.id || index} />;
1294
+ return null;
1295
+ })}
1296
+ </article>
1297
+ </main>
1298
+ );
682
1299
  }
683
1300
 
684
1301
  function ThemeComponentSection(props: ThemeSectionRendererProps) {
685
1302
  const { section } = props;
686
1303
  const componentKey = dataString(section.data, "componentKey");
687
1304
  const values = dataRecord(section.data, "props");
688
- if (componentKey === "contact-form" || componentKey.endsWith("-form")) return <ContactFormComponent {...props} />;
689
- if (componentKey === "video") return <section className="store-section theme-component-section" data-component-key="video"><div className="store-container">
690
- {dataString(values, "eyebrow") && <span>{dataString(values, "eyebrow")}</span>}
691
- {dataString(values, "title") && <h2>{dataString(values, "title")}</h2>}
692
- {dataString(values, "description") && <p>{dataString(values, "description")}</p>}
693
- {dataString(values, "videoUrl") && <video className="theme-component-video" controls playsInline poster={dataString(values, "posterImageUrl") || undefined} src={dataString(values, "videoUrl")} />}
694
- </div></section>;
1305
+ if (componentKey === "contact-form" || componentKey.endsWith("-form"))
1306
+ return <ContactFormComponent {...props} />;
1307
+ if (componentKey === "video")
1308
+ return (
1309
+ <section
1310
+ className="store-section theme-component-section"
1311
+ data-component-key="video"
1312
+ >
1313
+ <div className="store-container">
1314
+ {dataString(values, "eyebrow") && (
1315
+ <span>{dataString(values, "eyebrow")}</span>
1316
+ )}
1317
+ {dataString(values, "title") && (
1318
+ <h2>{dataString(values, "title")}</h2>
1319
+ )}
1320
+ {dataString(values, "description") && (
1321
+ <p>{dataString(values, "description")}</p>
1322
+ )}
1323
+ {dataString(values, "videoUrl") && (
1324
+ <video
1325
+ className="theme-component-video"
1326
+ controls
1327
+ playsInline
1328
+ poster={dataString(values, "posterImageUrl") || undefined}
1329
+ src={dataString(values, "videoUrl")}
1330
+ />
1331
+ )}
1332
+ </div>
1333
+ </section>
1334
+ );
695
1335
 
696
1336
  const items = dataRecords(values, "items");
697
- return <section className="store-section theme-component-section" data-component-key={componentKey || undefined}><div className="store-container">
698
- {dataString(values, "eyebrow") && <span>{dataString(values, "eyebrow")}</span>}
699
- {dataString(values, "title") && <h2>{dataString(values, "title")}</h2>}
700
- {dataString(values, "description") && <p>{dataString(values, "description")}</p>}
701
- {items.length > 0 && <div className="theme-component-items">{items.map((item, index) => <article key={index}>
702
- <strong>{dataString(item, "value", dataString(item, "title", dataString(item, "question", `Item ${index + 1}`)))}</strong>
703
- {dataString(item, "description", dataString(item, "answer")) && <p>{dataString(item, "description", dataString(item, "answer"))}</p>}
704
- </article>)}</div>}
705
- </div></section>;
706
- }
707
-
708
- function ProductsSection({ section, context, adapters }: ThemeSectionRendererProps) {
1337
+ return (
1338
+ <section
1339
+ className="store-section theme-component-section"
1340
+ data-component-key={componentKey || undefined}
1341
+ >
1342
+ <div className="store-container">
1343
+ {dataString(values, "eyebrow") && (
1344
+ <span>{dataString(values, "eyebrow")}</span>
1345
+ )}
1346
+ {dataString(values, "title") && <h2>{dataString(values, "title")}</h2>}
1347
+ {dataString(values, "description") && (
1348
+ <p>{dataString(values, "description")}</p>
1349
+ )}
1350
+ {items.length > 0 && (
1351
+ <div className="theme-component-items">
1352
+ {items.map((item, index) => (
1353
+ <article key={index}>
1354
+ <strong>
1355
+ {dataString(
1356
+ item,
1357
+ "value",
1358
+ dataString(
1359
+ item,
1360
+ "title",
1361
+ dataString(item, "question", `Item ${index + 1}`),
1362
+ ),
1363
+ )}
1364
+ </strong>
1365
+ {dataString(
1366
+ item,
1367
+ "description",
1368
+ dataString(item, "answer"),
1369
+ ) && (
1370
+ <p>
1371
+ {dataString(
1372
+ item,
1373
+ "description",
1374
+ dataString(item, "answer"),
1375
+ )}
1376
+ </p>
1377
+ )}
1378
+ </article>
1379
+ ))}
1380
+ </div>
1381
+ )}
1382
+ </div>
1383
+ </section>
1384
+ );
1385
+ }
1386
+
1387
+ function ProductsSection({
1388
+ section,
1389
+ context,
1390
+ adapters,
1391
+ }: ThemeSectionRendererProps) {
709
1392
  const categorySlug = dataString(section.data, "categorySlug");
710
1393
  const products = context.catalog.products
711
- .filter((product) => !categorySlug || product.categories.some((category) => category.slug === categorySlug) || product.categoryPath?.includes(categorySlug))
1394
+ .filter(
1395
+ (product) =>
1396
+ !categorySlug ||
1397
+ product.categories.some((category) => category.slug === categorySlug) ||
1398
+ product.categoryPath?.includes(categorySlug),
1399
+ )
712
1400
  .slice(0, dataLimit(section.data));
713
- return <section className="store-section"><div className="store-container">
714
- <div className="section-heading"><div><span>{dataString(section.data, "eyebrow", "Em destaque")}</span><h2>{dataString(section.data, "title", section.type === "products-grid" ? "Produtos em destaque" : "Vitrine de produtos")}</h2></div><adapters.Link href="/produtos">Ver todos</adapters.Link></div>
715
- {products.length ? section.type === "products-grid"
716
- ? <div className="product-grid" data-columns={context.site.settings?.catalog?.desktopColumns || 3}>{products.map((product) => <ProductCard adapters={adapters} context={context} product={product} key={product.slug} />)}</div>
717
- : <div className="product-carousel"><div className="product-carousel-track">{products.map((product) => <div className="product-carousel-item" key={product.slug}><ProductCard adapters={adapters} context={context} product={product} /></div>)}</div></div>
718
- : <div className="empty-state"><span>7</span><h2>Nenhum produto encontrado</h2><p>Escolha outra categoria ou publique produtos para esta vitrine.</p></div>}
719
- </div></section>;
1401
+ return (
1402
+ <section className="store-section">
1403
+ <div className="store-container">
1404
+ <div className="section-heading">
1405
+ <div>
1406
+ <span>{dataString(section.data, "eyebrow", "Em destaque")}</span>
1407
+ <h2>
1408
+ {dataString(
1409
+ section.data,
1410
+ "title",
1411
+ section.type === "products-grid"
1412
+ ? "Produtos em destaque"
1413
+ : "Vitrine de produtos",
1414
+ )}
1415
+ </h2>
1416
+ </div>
1417
+ <adapters.Link href="/produtos">Ver todos</adapters.Link>
1418
+ </div>
1419
+ {products.length ? (
1420
+ section.type === "products-grid" ? (
1421
+ <div
1422
+ className="product-grid"
1423
+ data-columns={context.site.settings?.catalog?.desktopColumns || 3}
1424
+ >
1425
+ {products.map((product) => (
1426
+ <ProductCard
1427
+ adapters={adapters}
1428
+ context={context}
1429
+ product={product}
1430
+ key={product.slug}
1431
+ />
1432
+ ))}
1433
+ </div>
1434
+ ) : (
1435
+ <div className="product-carousel">
1436
+ <div className="product-carousel-track">
1437
+ {products.map((product) => (
1438
+ <div className="product-carousel-item" key={product.slug}>
1439
+ <ProductCard
1440
+ adapters={adapters}
1441
+ context={context}
1442
+ product={product}
1443
+ />
1444
+ </div>
1445
+ ))}
1446
+ </div>
1447
+ </div>
1448
+ )
1449
+ ) : (
1450
+ <div className="empty-state">
1451
+ <span>7</span>
1452
+ <h2>Nenhum produto encontrado</h2>
1453
+ <p>
1454
+ Escolha outra categoria ou publique produtos para esta vitrine.
1455
+ </p>
1456
+ </div>
1457
+ )}
1458
+ </div>
1459
+ </section>
1460
+ );
720
1461
  }
721
1462
 
722
- function EditorialCards({ items, basePath, adapters }: {
1463
+ function EditorialCards({
1464
+ items,
1465
+ basePath,
1466
+ adapters,
1467
+ }: {
723
1468
  items: ThemeEditorialItem[];
724
1469
  basePath: string;
725
1470
  adapters: ThemeRuntimeAdapters;
726
1471
  }) {
727
1472
  const { Link, Image } = adapters;
728
- if (!items.length) return <div className="empty-state"><span>7</span><h2>Nenhum conteúdo publicado</h2><p>As publicações aparecerão aqui quando estiverem disponíveis.</p></div>;
729
- return <div className="editorial-grid">{items.map((item) => <article className="editorial-card" key={item.slug}>
730
- <Link className="editorial-card-image" href={`${basePath}/${item.slug}`}><Image image={item.image ?? null} fallbackAlt={item.title} /></Link>
731
- <div className="editorial-card-content">{item.category?.title && <span>{item.category.title}</span>}<h2><Link href={`${basePath}/${item.slug}`}>{item.title}</Link></h2><p>{item.description}</p><Link className="text-link" href={`${basePath}/${item.slug}`}>Saiba mais <span>→</span></Link></div>
732
- </article>)}</div>;
733
- }
734
-
735
- function AutomaticSection({ section, context, adapters }: ThemeSectionRendererProps) {
736
- const titles: Partial<Record<ThemeHomeSectionType, string>> = { "services-grid": "Nossos serviços", "blog-grid": "Conteúdos recentes", "cases-grid": "Cases e resultados" };
737
- const paths: Partial<Record<ThemeHomeSectionType, string>> = { "services-grid": "/servicos", "blog-grid": "/blog", "cases-grid": "/cases" };
738
- const items = section.type === "services-grid"
739
- ? context.editorial.services
740
- : section.type === "cases-grid"
741
- ? context.editorial.cases
742
- : context.editorial.posts;
1473
+ if (!items.length)
1474
+ return (
1475
+ <div className="empty-state">
1476
+ <span>7</span>
1477
+ <h2>Nenhum conteúdo publicado</h2>
1478
+ <p>As publicações aparecerão aqui quando estiverem disponíveis.</p>
1479
+ </div>
1480
+ );
1481
+ return (
1482
+ <div className="editorial-grid">
1483
+ {items.map((item) => (
1484
+ <article className="editorial-card" key={item.slug}>
1485
+ <Link
1486
+ className="editorial-card-image"
1487
+ href={
1488
+ "href" in item && typeof item.href === "string"
1489
+ ? item.href
1490
+ : `${basePath}/${item.slug}`
1491
+ }
1492
+ >
1493
+ <Image image={item.image ?? null} fallbackAlt={item.title} />
1494
+ </Link>
1495
+ <div className="editorial-card-content">
1496
+ {item.category?.title && <span>{item.category.title}</span>}
1497
+ <h2>
1498
+ <Link
1499
+ href={
1500
+ "href" in item && typeof item.href === "string"
1501
+ ? item.href
1502
+ : `${basePath}/${item.slug}`
1503
+ }
1504
+ >
1505
+ {item.title}
1506
+ </Link>
1507
+ </h2>
1508
+ <p>{item.description}</p>
1509
+ <Link
1510
+ className="text-link"
1511
+ href={
1512
+ "href" in item && typeof item.href === "string"
1513
+ ? item.href
1514
+ : `${basePath}/${item.slug}`
1515
+ }
1516
+ >
1517
+ Saiba mais <span>→</span>
1518
+ </Link>
1519
+ </div>
1520
+ </article>
1521
+ ))}
1522
+ </div>
1523
+ );
1524
+ }
1525
+
1526
+ function AutomaticSection({
1527
+ section,
1528
+ context,
1529
+ adapters,
1530
+ }: ThemeSectionRendererProps) {
1531
+ const titles: Partial<Record<ThemeHomeSectionType, string>> = {
1532
+ "services-grid": "Nossos serviços",
1533
+ "blog-grid": "Conteúdos recentes",
1534
+ "cases-grid": "Cases e resultados",
1535
+ };
1536
+ const paths: Partial<Record<ThemeHomeSectionType, string>> = {
1537
+ "services-grid": "/servicos",
1538
+ "blog-grid": "/blog",
1539
+ "cases-grid": "/cases",
1540
+ };
1541
+ const items =
1542
+ section.type === "services-grid"
1543
+ ? context.editorial.services
1544
+ : section.type === "cases-grid"
1545
+ ? context.editorial.cases
1546
+ : context.editorial.posts;
743
1547
  const basePath = paths[section.type] || "/";
744
- return <section className="store-section"><div className="store-container">
745
- <div className="section-heading"><div><span>{dataString(section.data, "eyebrow", "Em destaque")}</span><h2>{dataString(section.data, "title", titles[section.type] || "Conteúdo")}</h2></div><adapters.Link href={basePath}>Ver todos</adapters.Link></div>
746
- <EditorialCards adapters={adapters} basePath={basePath} items={items.slice(0, dataLimit(section.data))} />
747
- </div></section>;
1548
+ return (
1549
+ <section className="store-section">
1550
+ <div className="store-container">
1551
+ <div className="section-heading">
1552
+ <div>
1553
+ <span>{dataString(section.data, "eyebrow", "Em destaque")}</span>
1554
+ <h2>
1555
+ {dataString(
1556
+ section.data,
1557
+ "title",
1558
+ titles[section.type] || "Conteúdo",
1559
+ )}
1560
+ </h2>
1561
+ </div>
1562
+ <adapters.Link href={basePath}>Ver todos</adapters.Link>
1563
+ </div>
1564
+ <EditorialCards
1565
+ adapters={adapters}
1566
+ basePath={basePath}
1567
+ items={items.slice(0, dataLimit(section.data))}
1568
+ />
1569
+ </div>
1570
+ </section>
1571
+ );
748
1572
  }
749
1573
 
750
1574
  export const defaultSectionRegistry: ThemeSectionRegistry = {
@@ -763,12 +1587,23 @@ export const defaultSectionRegistry: ThemeSectionRegistry = {
763
1587
  };
764
1588
 
765
1589
  function fallbackSections(context: ThemeContext): ThemeHomeSection[] {
766
- const sections: ThemeHomeSection[] = [{ type: "hero", enabled: true, order: 0, data: {} }];
767
- if (context.site.modules.includes("PRODUCTS")) sections.push({ type: "products-carousel", enabled: true, order: 1, data: { limit: 8 } });
1590
+ const sections: ThemeHomeSection[] = [
1591
+ { type: "hero", enabled: true, order: 0, data: {} },
1592
+ ];
1593
+ if (context.site.modules.includes("PRODUCTS"))
1594
+ sections.push({
1595
+ type: "products-carousel",
1596
+ enabled: true,
1597
+ order: 1,
1598
+ data: { limit: 8 },
1599
+ });
768
1600
  return sections;
769
1601
  }
770
1602
 
771
- function findCategory(categories: ThemeCategory[], slug: string | null): ThemeCategory | null {
1603
+ function findCategory(
1604
+ categories: ThemeCategory[],
1605
+ slug: string | null,
1606
+ ): ThemeCategory | null {
772
1607
  if (!slug) return null;
773
1608
  for (const category of categories) {
774
1609
  if (category.slug === slug) return category;
@@ -778,12 +1613,17 @@ function findCategory(categories: ThemeCategory[], slug: string | null): ThemeCa
778
1613
  return null;
779
1614
  }
780
1615
 
781
- function catalogHref(route: Extract<ThemeRoute, { type: "catalog" }>, page: number): string {
1616
+ function catalogHref(
1617
+ route: Extract<ThemeRoute, { type: "catalog" }>,
1618
+ page: number,
1619
+ ): string {
782
1620
  const params = new URLSearchParams();
783
1621
  if (route.search) params.set("busca", route.search);
784
1622
  route.variants.forEach((variant) => params.append("variante", variant));
785
1623
  if (page > 1) params.set("pagina", String(page));
786
- const pathname = route.categoryPath.length ? categoryUrl(route.categoryPath) : "/produtos";
1624
+ const pathname = route.categoryPath.length
1625
+ ? categoryUrl(route.categoryPath)
1626
+ : "/produtos";
787
1627
  return params.size ? `${pathname}?${params}` : pathname;
788
1628
  }
789
1629
 
@@ -793,7 +1633,11 @@ function pageNumbers(current: number, total: number): number[] {
793
1633
  .sort((a, b) => a - b);
794
1634
  }
795
1635
 
796
- function CatalogPage({ route, context, adapters }: {
1636
+ function CatalogPage({
1637
+ route,
1638
+ context,
1639
+ adapters,
1640
+ }: {
797
1641
  route: Extract<ThemeRoute, { type: "catalog" }>;
798
1642
  context: ThemeContext;
799
1643
  adapters: ThemeRuntimeAdapters;
@@ -801,78 +1645,351 @@ function CatalogPage({ route, context, adapters }: {
801
1645
  const { Link } = adapters;
802
1646
  const selected = findCategory(route.categories, route.categorySlug);
803
1647
  const catalog = context.site.settings?.catalog ?? fallbackCatalog;
804
- return <main className="catalog-page">
805
- <section className="catalog-hero"><div className="store-container"><span>Nosso catálogo</span><h1>{route.search ? `Busca por “${route.search}”` : selected?.name || "Todos os produtos"}</h1><p>{route.search ? `${route.pagination.total} resultado${route.pagination.total === 1 ? "" : "s"} encontrado${route.pagination.total === 1 ? "" : "s"}.` : selected?.description || "Encontre o produto certo para o que você precisa."}</p></div></section>
806
- <div className="store-container catalog-layout">
807
- <aside className="category-filter catalog-filters">
808
- <form action={route.categoryPath.length ? categoryUrl(route.categoryPath) : "/produtos"} className="catalog-filter-form"><label htmlFor="theme-catalog-search">Buscar no catálogo</label><div className="catalog-filter-search"><input id="theme-catalog-search" name="busca" type="search" defaultValue={route.search} placeholder="Nome do produto" /><button type="submit" aria-label="Pesquisar"><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7" /><path d="m16.5 16.5 4 4" /></svg></button></div></form>
809
- <div className="catalog-filter-section catalog-category-tree"><strong>Categorias</strong><Link className={!route.categorySlug ? "active" : ""} href="/produtos">Todos os produtos</Link><CategoryTree adapters={adapters} categories={route.categories} /></div>
810
- {route.facets.length > 0 && <form action={route.categoryPath.length ? categoryUrl(route.categoryPath) : "/produtos"} className="catalog-variant-filters">
811
- {route.search && <input type="hidden" name="busca" value={route.search} />}
812
- {route.facets.map((facet) => <fieldset className="catalog-filter-section" key={facet.name}><legend>{facet.name}</legend>{facet.values.map(({ value, count }) => { const token = `${facet.name}::${value}`; return <label className="catalog-filter-checkbox" key={token}><input type="checkbox" name="variante" value={token} defaultChecked={route.variants.includes(token)} /><span>{value}</span><small>{count}</small></label>; })}</fieldset>)}
813
- <button type="submit" className="button button-primary button-block">Aplicar filtros</button>
814
- </form>}
815
- {(route.categorySlug || route.search || route.variants.length) && <Link className="catalog-clear-filters" href="/produtos">Limpar todos os filtros</Link>}
816
- </aside>
817
- <section className="catalog-results">
818
- <div className="catalog-toolbar"><span>{route.pagination.total} {route.pagination.total === 1 ? "produto" : "produtos"}</span></div>
819
- {route.products.length ? <div className="product-grid" data-columns={catalog.desktopColumns}>{route.products.map((product) => <ProductCard adapters={adapters} context={context} product={product} key={product.slug} />)}</div> : <div className="empty-state"><span>7</span><h2>Nenhum produto encontrado</h2><p>Novos itens aparecerão aqui assim que forem publicados.</p></div>}
820
- {route.pagination.totalPages > 1 && <nav className="catalog-pagination" aria-label="Paginação dos produtos">
821
- <Link className={!route.pagination.hasPreviousPage ? "disabled" : ""} href={catalogHref(route, Math.max(1, route.pagination.page - 1))}><span>‹</span> Anterior</Link>
822
- <div className="catalog-pagination-pages">{pageNumbers(route.pagination.page, route.pagination.totalPages).map((page, index, pages) => <span className="catalog-pagination-item" key={page}>{index > 0 && page - pages[index - 1] > 1 && <span className="catalog-pagination-ellipsis">…</span>}<Link className={page === route.pagination.page ? "active" : ""} href={catalogHref(route, page)}>{page}</Link></span>)}</div>
823
- <Link className={!route.pagination.hasNextPage ? "disabled" : ""} href={catalogHref(route, route.pagination.page + 1)}>Próxima <span>›</span></Link>
824
- </nav>}
1648
+ return (
1649
+ <main className="catalog-page">
1650
+ <section className="catalog-hero">
1651
+ <div className="store-container">
1652
+ <span>Nosso catálogo</span>
1653
+ <h1>
1654
+ {route.search
1655
+ ? `Busca por “${route.search}”`
1656
+ : selected?.name || "Todos os produtos"}
1657
+ </h1>
1658
+ <p>
1659
+ {route.search
1660
+ ? `${route.pagination.total} resultado${route.pagination.total === 1 ? "" : "s"} encontrado${route.pagination.total === 1 ? "" : "s"}.`
1661
+ : selected?.description ||
1662
+ "Encontre o produto certo para o que você precisa."}
1663
+ </p>
1664
+ </div>
825
1665
  </section>
826
- </div>
827
- </main>;
1666
+ <div className="store-container catalog-layout">
1667
+ <aside className="category-filter catalog-filters">
1668
+ <form
1669
+ action={
1670
+ route.categoryPath.length
1671
+ ? categoryUrl(route.categoryPath)
1672
+ : "/produtos"
1673
+ }
1674
+ className="catalog-filter-form"
1675
+ >
1676
+ <label htmlFor="theme-catalog-search">Buscar no catálogo</label>
1677
+ <div className="catalog-filter-search">
1678
+ <input
1679
+ id="theme-catalog-search"
1680
+ name="busca"
1681
+ type="search"
1682
+ defaultValue={route.search}
1683
+ placeholder="Nome do produto"
1684
+ />
1685
+ <button type="submit" aria-label="Pesquisar">
1686
+ <svg viewBox="0 0 24 24" aria-hidden="true">
1687
+ <circle cx="11" cy="11" r="7" />
1688
+ <path d="m16.5 16.5 4 4" />
1689
+ </svg>
1690
+ </button>
1691
+ </div>
1692
+ </form>
1693
+ <div className="catalog-filter-section catalog-category-tree">
1694
+ <strong>Categorias</strong>
1695
+ <Link
1696
+ className={!route.categorySlug ? "active" : ""}
1697
+ href="/produtos"
1698
+ >
1699
+ Todos os produtos
1700
+ </Link>
1701
+ <CategoryTree adapters={adapters} categories={route.categories} />
1702
+ </div>
1703
+ {route.facets.length > 0 && (
1704
+ <form
1705
+ action={
1706
+ route.categoryPath.length
1707
+ ? categoryUrl(route.categoryPath)
1708
+ : "/produtos"
1709
+ }
1710
+ className="catalog-variant-filters"
1711
+ >
1712
+ {route.search && (
1713
+ <input type="hidden" name="busca" value={route.search} />
1714
+ )}
1715
+ {route.facets.map((facet) => (
1716
+ <fieldset className="catalog-filter-section" key={facet.name}>
1717
+ <legend>{facet.name}</legend>
1718
+ {facet.values.map(({ value, count }) => {
1719
+ const token = `${facet.name}::${value}`;
1720
+ return (
1721
+ <label className="catalog-filter-checkbox" key={token}>
1722
+ <input
1723
+ type="checkbox"
1724
+ name="variante"
1725
+ value={token}
1726
+ defaultChecked={route.variants.includes(token)}
1727
+ />
1728
+ <span>{value}</span>
1729
+ <small>{count}</small>
1730
+ </label>
1731
+ );
1732
+ })}
1733
+ </fieldset>
1734
+ ))}
1735
+ <button
1736
+ type="submit"
1737
+ className="button button-primary button-block"
1738
+ >
1739
+ Aplicar filtros
1740
+ </button>
1741
+ </form>
1742
+ )}
1743
+ {(route.categorySlug || route.search || route.variants.length) && (
1744
+ <Link className="catalog-clear-filters" href="/produtos">
1745
+ Limpar todos os filtros
1746
+ </Link>
1747
+ )}
1748
+ </aside>
1749
+ <section className="catalog-results">
1750
+ <div className="catalog-toolbar">
1751
+ <span>
1752
+ {route.pagination.total}{" "}
1753
+ {route.pagination.total === 1 ? "produto" : "produtos"}
1754
+ </span>
1755
+ </div>
1756
+ {route.products.length ? (
1757
+ <div className="product-grid" data-columns={catalog.desktopColumns}>
1758
+ {route.products.map((product) => (
1759
+ <ProductCard
1760
+ adapters={adapters}
1761
+ context={context}
1762
+ product={product}
1763
+ key={product.slug}
1764
+ />
1765
+ ))}
1766
+ </div>
1767
+ ) : (
1768
+ <div className="empty-state">
1769
+ <span>7</span>
1770
+ <h2>Nenhum produto encontrado</h2>
1771
+ <p>Novos itens aparecerão aqui assim que forem publicados.</p>
1772
+ </div>
1773
+ )}
1774
+ {route.pagination.totalPages > 1 && (
1775
+ <nav
1776
+ className="catalog-pagination"
1777
+ aria-label="Paginação dos produtos"
1778
+ >
1779
+ <Link
1780
+ className={!route.pagination.hasPreviousPage ? "disabled" : ""}
1781
+ href={catalogHref(
1782
+ route,
1783
+ Math.max(1, route.pagination.page - 1),
1784
+ )}
1785
+ >
1786
+ <span>‹</span> Anterior
1787
+ </Link>
1788
+ <div className="catalog-pagination-pages">
1789
+ {pageNumbers(
1790
+ route.pagination.page,
1791
+ route.pagination.totalPages,
1792
+ ).map((page, index, pages) => (
1793
+ <span className="catalog-pagination-item" key={page}>
1794
+ {index > 0 && page - pages[index - 1] > 1 && (
1795
+ <span className="catalog-pagination-ellipsis">…</span>
1796
+ )}
1797
+ <Link
1798
+ className={page === route.pagination.page ? "active" : ""}
1799
+ href={catalogHref(route, page)}
1800
+ >
1801
+ {page}
1802
+ </Link>
1803
+ </span>
1804
+ ))}
1805
+ </div>
1806
+ <Link
1807
+ className={!route.pagination.hasNextPage ? "disabled" : ""}
1808
+ href={catalogHref(route, route.pagination.page + 1)}
1809
+ >
1810
+ Próxima <span>›</span>
1811
+ </Link>
1812
+ </nav>
1813
+ )}
1814
+ </section>
1815
+ </div>
1816
+ </main>
1817
+ );
828
1818
  }
829
1819
 
830
- function ProductPage({ product, context, adapters }: {
1820
+ function ProductPage({
1821
+ product,
1822
+ context,
1823
+ adapters,
1824
+ }: {
831
1825
  product: ThemeProduct;
832
1826
  context: ThemeContext;
833
1827
  adapters: ThemeRuntimeAdapters;
834
1828
  }) {
835
1829
  const { Link, Image } = adapters;
836
- const [selectedVariantId, setSelectedVariantId] = useState<string | null>(null);
837
- const selectedVariant = product.variants.find((variant) => variant.id === selectedVariantId);
1830
+ const [selectedVariantId, setSelectedVariantId] = useState<string | null>(
1831
+ null,
1832
+ );
1833
+ const selectedVariant = product.variants.find(
1834
+ (variant) => variant.id === selectedVariantId,
1835
+ );
838
1836
  const images = useMemo(() => {
839
1837
  if (selectedVariant?.image?.url) return [selectedVariant.image];
840
1838
  const unique = new Map<string, NonNullable<typeof product.image>>();
841
- [product.image, ...product.images].forEach((image) => { if (image?.url) unique.set(image.url, image); });
1839
+ [product.image, ...product.images].forEach((image) => {
1840
+ if (image?.url) unique.set(image.url, image);
1841
+ });
842
1842
  return [...unique.values()];
843
1843
  }, [product.image, product.images, selectedVariant]);
844
1844
  const [selectedImageUrl, setSelectedImageUrl] = useState<string | null>(null);
845
- const selectedImage = images.find((image) => image.url === selectedImageUrl) || images[0] || product.image;
1845
+ const selectedImage =
1846
+ images.find((image) => image.url === selectedImageUrl) ||
1847
+ images[0] ||
1848
+ product.image;
846
1849
  const showPrices = context.site.settings?.catalog?.showPrices ?? true;
847
1850
  const whatsapp = context.site.settings?.contact.whatsapp?.replace(/\D/g, "");
848
- const priceText = showPrices && displayPrice(product) ? ` Valor: ${displayPrice(product)}.` : "";
849
- const quoteUrl = whatsapp ? `https://wa.me/${whatsapp}?text=${encodeURIComponent(`Olá! Gostaria de solicitar um orçamento para ${product.title}.${priceText}`)}` : null;
850
-
851
- return <main className="product-page"><div className="store-container">
852
- <nav className="breadcrumbs"><Link href="/">Início</Link><span>/</span><Link href="/produtos">Produtos</Link><span>/</span><strong>{product.title}</strong></nav>
853
- <div className="product-detail">
854
- <div className="product-gallery"><div className="product-main-image"><Image image={selectedImage} fallbackAlt={selectedVariant?.name || product.title} priority /></div>{images.length > 1 && <div className="product-thumbnails">{images.map((image, index) => <button className={selectedImage?.url === image.url ? "active" : ""} type="button" onClick={() => setSelectedImageUrl(image.url)} key={`${image.url}-${index}`}><Image image={image} fallbackAlt={`${product.title} ${index + 1}`} /></button>)}</div>}</div>
855
- <div className="product-info">{product.categories[0] && <span className="product-category">{product.categories[0].name}</span>}<h1>{product.title}</h1>{showPrices && displayPrice(product) && <strong>{displayPrice(product)}</strong>}<div className="product-description">{plainText(product.description)}</div>
856
- {product.variants.length > 0 && <div className="variant-selector"><fieldset><legend>Escolha uma variação</legend><div className="variant-values">{product.variants.filter((variant) => variant.active).map((variant) => <button className={variant.id === selectedVariantId ? "active" : ""} type="button" key={variant.id || variant.sku} onClick={() => { setSelectedVariantId(variant.id); setSelectedImageUrl(null); }}>{variant.name || variant.values.map((value) => value.value).join(" / ")}</button>)}</div></fieldset></div>}
857
- <div className="product-purchase">{quoteUrl ? <a className="button button-primary button-block" href={quoteUrl} target="_blank" rel="noreferrer">Solicitar orçamento pelo WhatsApp</a> : <span className="button button-secondary button-block">Entre em contato para orçar</span>}</div>
858
- <div className="purchase-benefits"><span><strong>Atendimento direto</strong> Fale com quem entende do produto</span><span><strong>Orçamento personalizado</strong> Condições para a sua necessidade</span></div>
1851
+ const priceText =
1852
+ showPrices && displayPrice(product)
1853
+ ? ` Valor: ${displayPrice(product)}.`
1854
+ : "";
1855
+ const quoteUrl = whatsapp
1856
+ ? `https://wa.me/${whatsapp}?text=${encodeURIComponent(`Olá! Gostaria de solicitar um orçamento para ${product.title}.${priceText}`)}`
1857
+ : null;
1858
+
1859
+ return (
1860
+ <main className="product-page">
1861
+ <div className="store-container">
1862
+ <nav className="breadcrumbs">
1863
+ <Link href="/">Início</Link>
1864
+ <span>/</span>
1865
+ <Link href="/produtos">Produtos</Link>
1866
+ <span>/</span>
1867
+ <strong>{product.title}</strong>
1868
+ </nav>
1869
+ <div className="product-detail">
1870
+ <div className="product-gallery">
1871
+ <div className="product-main-image">
1872
+ <Image
1873
+ image={selectedImage}
1874
+ fallbackAlt={selectedVariant?.name || product.title}
1875
+ priority
1876
+ />
1877
+ </div>
1878
+ {images.length > 1 && (
1879
+ <div className="product-thumbnails">
1880
+ {images.map((image, index) => (
1881
+ <button
1882
+ className={selectedImage?.url === image.url ? "active" : ""}
1883
+ type="button"
1884
+ onClick={() => setSelectedImageUrl(image.url)}
1885
+ key={`${image.url}-${index}`}
1886
+ >
1887
+ <Image
1888
+ image={image}
1889
+ fallbackAlt={`${product.title} ${index + 1}`}
1890
+ />
1891
+ </button>
1892
+ ))}
1893
+ </div>
1894
+ )}
1895
+ </div>
1896
+ <div className="product-info">
1897
+ {product.categories[0] && (
1898
+ <span className="product-category">
1899
+ {product.categories[0].name}
1900
+ </span>
1901
+ )}
1902
+ <h1>{product.title}</h1>
1903
+ {showPrices && displayPrice(product) && (
1904
+ <strong>{displayPrice(product)}</strong>
1905
+ )}
1906
+ <div className="product-description">
1907
+ {plainText(product.description)}
1908
+ </div>
1909
+ {product.variants.length > 0 && (
1910
+ <div className="variant-selector">
1911
+ <fieldset>
1912
+ <legend>Escolha uma variação</legend>
1913
+ <div className="variant-values">
1914
+ {product.variants
1915
+ .filter((variant) => variant.active)
1916
+ .map((variant) => (
1917
+ <button
1918
+ className={
1919
+ variant.id === selectedVariantId ? "active" : ""
1920
+ }
1921
+ type="button"
1922
+ key={variant.id || variant.sku}
1923
+ onClick={() => {
1924
+ setSelectedVariantId(variant.id);
1925
+ setSelectedImageUrl(null);
1926
+ }}
1927
+ >
1928
+ {variant.name ||
1929
+ variant.values
1930
+ .map((value) => value.value)
1931
+ .join(" / ")}
1932
+ </button>
1933
+ ))}
1934
+ </div>
1935
+ </fieldset>
1936
+ </div>
1937
+ )}
1938
+ <div className="product-purchase">
1939
+ {quoteUrl ? (
1940
+ <a
1941
+ className="button button-primary button-block"
1942
+ href={quoteUrl}
1943
+ target="_blank"
1944
+ rel="noreferrer"
1945
+ >
1946
+ Solicitar orçamento pelo WhatsApp
1947
+ </a>
1948
+ ) : (
1949
+ <span className="button button-secondary button-block">
1950
+ Entre em contato para orçar
1951
+ </span>
1952
+ )}
1953
+ </div>
1954
+ <div className="purchase-benefits">
1955
+ <span>
1956
+ <strong>Atendimento direto</strong> Fale com quem entende do
1957
+ produto
1958
+ </span>
1959
+ <span>
1960
+ <strong>Orçamento personalizado</strong> Condições para a sua
1961
+ necessidade
1962
+ </span>
1963
+ </div>
1964
+ </div>
1965
+ </div>
859
1966
  </div>
860
- </div>
861
- </div></main>;
1967
+ </main>
1968
+ );
862
1969
  }
863
1970
 
864
1971
  /** Fallback seguro para consumidores que usam um tema sem componente NotFound. */
865
1972
  export function DefaultNotFound({ homeHref = "/" }: NotFoundProps) {
866
- return <main className="not-found-page">
867
- <div className="not-found-card">
868
- <span>404</span>
869
- <h1>Conteúdo não encontrado</h1>
870
- <a className="button button-primary" href={homeHref}>Voltar ao início</a>
871
- </div>
872
- </main>;
1973
+ return (
1974
+ <main className="not-found-page">
1975
+ <div className="not-found-card">
1976
+ <span>404</span>
1977
+ <h1>Conteúdo não encontrado</h1>
1978
+ <a className="button button-primary" href={homeHref}>
1979
+ Voltar ao início
1980
+ </a>
1981
+ </div>
1982
+ </main>
1983
+ );
873
1984
  }
874
1985
 
875
- function RouteContent({ route, context, adapters, home, sdk }: {
1986
+ function RouteContent({
1987
+ route,
1988
+ context,
1989
+ adapters,
1990
+ home,
1991
+ sdk,
1992
+ }: {
876
1993
  route: ThemeRoute;
877
1994
  context: ThemeContext;
878
1995
  adapters: ThemeRuntimeAdapters;
@@ -880,13 +1997,64 @@ function RouteContent({ route, context, adapters, home, sdk }: {
880
1997
  sdk?: ThemeRuntimeSdk;
881
1998
  }) {
882
1999
  if (route.type === "home") return home;
883
- if (route.type === "loading") return <main className="not-found-page"><div className="not-found-card"><span>Carregando</span><h1>Buscando conteúdo da loja</h1></div></main>;
2000
+ if (route.type === "loading")
2001
+ return (
2002
+ <main className="not-found-page">
2003
+ <div className="not-found-card">
2004
+ <span>Carregando</span>
2005
+ <h1>Buscando conteúdo da loja</h1>
2006
+ </div>
2007
+ </main>
2008
+ );
884
2009
  if (route.type === "not-found") return <DefaultNotFound homeHref="/" />;
885
- if (route.type === "catalog") return <CatalogPage adapters={adapters} context={context} route={route} />;
886
- if (route.type === "product") return <ProductPage adapters={adapters} context={context} product={route.product} />;
887
- if (route.type === "editorial-list") return <main className="catalog-page"><section className="catalog-hero"><div className="store-container"><span>Conteúdo</span><h1>{route.title}</h1></div></section><section className="store-section"><div className="store-container"><EditorialCards adapters={adapters} basePath={route.basePath} items={route.items} /></div></section></main>;
888
- if (route.type === "editorial-detail") return <main className="store-section"><article className="store-container editorial-content"><span>Conteúdo</span><h1>{route.item.title}</h1><p>{route.item.description}</p></article></main>;
889
- return <PageContent adapters={adapters} context={context} route={route} sdk={sdk} />;
2010
+ if (route.type === "catalog")
2011
+ return <CatalogPage adapters={adapters} context={context} route={route} />;
2012
+ if (route.type === "product")
2013
+ return (
2014
+ <ProductPage
2015
+ adapters={adapters}
2016
+ context={context}
2017
+ product={route.product}
2018
+ />
2019
+ );
2020
+ if (route.type === "editorial-list")
2021
+ return (
2022
+ <main className="catalog-page">
2023
+ <section className="catalog-hero">
2024
+ <div className="store-container">
2025
+ <span>Conteúdo</span>
2026
+ <h1>{route.title}</h1>
2027
+ </div>
2028
+ </section>
2029
+ <section className="store-section">
2030
+ <div className="store-container">
2031
+ <EditorialCards
2032
+ adapters={adapters}
2033
+ basePath={route.basePath}
2034
+ items={route.items}
2035
+ />
2036
+ </div>
2037
+ </section>
2038
+ </main>
2039
+ );
2040
+ if (route.type === "editorial-detail")
2041
+ return (
2042
+ <main className="store-section">
2043
+ <article className="store-container editorial-content">
2044
+ <span>Conteúdo</span>
2045
+ <h1>{route.item.title}</h1>
2046
+ <p>{route.item.description}</p>
2047
+ </article>
2048
+ </main>
2049
+ );
2050
+ return (
2051
+ <PageContent
2052
+ adapters={adapters}
2053
+ context={context}
2054
+ route={route}
2055
+ sdk={sdk}
2056
+ />
2057
+ );
890
2058
  }
891
2059
 
892
2060
  function Footer({ context, adapters }: DefaultThemeProps) {
@@ -894,14 +2062,56 @@ function Footer({ context, adapters }: DefaultThemeProps) {
894
2062
  const settings = context.site.settings;
895
2063
  const name = settings?.siteName || context.store.name;
896
2064
  const extraLinks = moduleLinks(context);
897
- return <footer className="store-footer">
898
- <div className="store-container footer-grid">
899
- <div><strong className="footer-brand">{(settings?.footerLogo ?? settings?.logo)?.url ? <adapters.Image image={settings?.footerLogo ?? settings?.logo ?? null} fallbackAlt={name} className="footer-logo" /> : name}</strong><p>{settings?.description || template.footerTagline}</p></div>
900
- <div><strong>Navegação</strong>{context.site.modules.includes("PRODUCTS") && <Link href="/produtos">Todos os produtos</Link>}{extraLinks.map((item) => <Link href={item.href} key={item.href}>{item.label}</Link>)}<Link href="/">Início</Link></div>
901
- <div><strong>Atendimento</strong>{settings?.contact.email && <a href={`mailto:${settings.contact.email}`}>{settings.contact.email}</a>}{settings?.contact.phone && <a href={`tel:${settings.contact.phone}`}>{settings.contact.phone}</a>}{settings?.contact.address && <span>{settings.contact.address}</span>}</div>
902
- </div>
903
- <div className="store-container footer-bottom"><span>© {new Date().getFullYear()} {name}</span><span>{template.footerNote}</span></div>
904
- </footer>;
2065
+ return (
2066
+ <footer className="store-footer">
2067
+ <div className="store-container footer-grid">
2068
+ <div>
2069
+ <strong className="footer-brand">
2070
+ {(settings?.footerLogo ?? settings?.logo)?.url ? (
2071
+ <adapters.Image
2072
+ image={settings?.footerLogo ?? settings?.logo ?? null}
2073
+ fallbackAlt={name}
2074
+ className="footer-logo"
2075
+ />
2076
+ ) : name}
2077
+ </strong>
2078
+ <p>{settings?.description || template.footerTagline}</p>
2079
+ </div>
2080
+ <div>
2081
+ <strong>Navegação</strong>
2082
+ {context.site.modules.includes("PRODUCTS") && (
2083
+ <Link href="/produtos">Todos os produtos</Link>
2084
+ )}
2085
+ {extraLinks.map((item) => (
2086
+ <Link href={item.href} key={item.href}>
2087
+ {item.label}
2088
+ </Link>
2089
+ ))}
2090
+ <Link href="/">Início</Link>
2091
+ </div>
2092
+ <div>
2093
+ <strong>Atendimento</strong>
2094
+ {settings?.contact.email && (
2095
+ <a href={`mailto:${settings.contact.email}`}>
2096
+ {settings.contact.email}
2097
+ </a>
2098
+ )}
2099
+ {settings?.contact.phone && (
2100
+ <a href={`tel:${settings.contact.phone}`}>
2101
+ {settings.contact.phone}
2102
+ </a>
2103
+ )}
2104
+ {settings?.contact.address && <span>{settings.contact.address}</span>}
2105
+ </div>
2106
+ </div>
2107
+ <div className="store-container footer-bottom">
2108
+ <span>
2109
+ © {new Date().getFullYear()} {name}
2110
+ </span>
2111
+ <span>{template.footerNote}</span>
2112
+ </div>
2113
+ </footer>
2114
+ );
905
2115
  }
906
2116
 
907
2117
  function FloatingWhatsapp({ context }: { context: ThemeContext }) {
@@ -911,10 +2121,28 @@ function FloatingWhatsapp({ context }: { context: ThemeContext }) {
911
2121
  if (!floating?.enabled || !phone) return null;
912
2122
  const label = floating.label?.trim() || "Fale conosco";
913
2123
  const url = `https://wa.me/${phone}?text=${encodeURIComponent(floating.message)}`;
914
- return <a className="floating-whatsapp" href={url} target="_blank" rel="noreferrer" aria-label={`${label} pelo WhatsApp`}><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479s1.065 2.875 1.213 3.074c.149.198 2.095 3.2 5.076 4.487.709.306 1.262.489 1.694.626.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.29.173-1.414-.074-.123-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 0 1-5.031-1.378l-.361-.214-3.741.981.998-3.648-.235-.374a9.86 9.86 0 0 1-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 0 1 2.9 6.986c-.002 5.45-4.437 9.884-9.892 9.884m8.413-18.297A11.815 11.815 0 0 0 12.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.3-1.654a11.882 11.882 0 0 0 5.689 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 0 0-3.48-8.413Z" /></svg><span>{label}</span></a>;
2124
+ return (
2125
+ <a
2126
+ className="floating-whatsapp"
2127
+ href={url}
2128
+ target="_blank"
2129
+ rel="noreferrer"
2130
+ aria-label={`${label} pelo WhatsApp`}
2131
+ >
2132
+ <svg viewBox="0 0 24 24" aria-hidden="true">
2133
+ <path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479s1.065 2.875 1.213 3.074c.149.198 2.095 3.2 5.076 4.487.709.306 1.262.489 1.694.626.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.29.173-1.414-.074-.123-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 0 1-5.031-1.378l-.361-.214-3.741.981.998-3.648-.235-.374a9.86 9.86 0 0 1-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 0 1 2.9 6.986c-.002 5.45-4.437 9.884-9.892 9.884m8.413-18.297A11.815 11.815 0 0 0 12.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.3-1.654a11.882 11.882 0 0 0 5.689 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 0 0-3.48-8.413Z" />
2134
+ </svg>
2135
+ <span>{label}</span>
2136
+ </a>
2137
+ );
915
2138
  }
916
2139
 
917
- export function DefaultTheme({ context, adapters, route = { type: "home" }, sdk }: DefaultThemeProps) {
2140
+ export function DefaultTheme({
2141
+ context,
2142
+ adapters,
2143
+ route = { type: "home" },
2144
+ sdk,
2145
+ }: DefaultThemeProps) {
918
2146
  const configured = context.site.settings?.theme;
919
2147
  const colors = { ...fallbackColors, ...configured?.colors };
920
2148
  const layout = configured?.layout;
@@ -937,18 +2165,65 @@ export function DefaultTheme({ context, adapters, route = { type: "home" }, sdk
937
2165
  "--container-width": `${layout?.containerWidth ?? 1280}px`,
938
2166
  "--border-radius": `${layout?.borderRadius ?? 18}px`,
939
2167
  } as CSSProperties;
940
- const visible = context.home.content.sections.filter((section) => section.enabled).sort((a, b) => a.order - b.order);
2168
+ const visible = context.home.content.sections
2169
+ .filter((section) => section.enabled)
2170
+ .sort((a, b) => a.order - b.order);
941
2171
  const sections = visible.length ? visible : fallbackSections(context);
942
2172
 
943
- return <div className="store-shell nuvler-default-theme" data-theme-id="nuvler-default" data-theme-version="1.0.2" style={style}>
944
- <Header adapters={adapters} context={context} />
945
- <div className="store-page"><RouteContent adapters={adapters} context={context} route={route} sdk={sdk} home={<main>{sections.map((section, index) => {
946
- const Renderer = defaultSectionRegistry[section.type];
947
- if (!Renderer) return null;
948
- const content = <Renderer adapters={adapters} context={context} key={`${section.type}-${section.order}-${index}`} sdk={sdk} section={section} />;
949
- return section.reference ? <div id={section.reference} key={`${section.type}-${section.order}-${index}`} style={{ scrollMarginTop: "100px" }}>{content}</div> : content;
950
- })}<section className="benefits-section"><div className="store-container benefits-grid">{template.benefits.map((benefit) => <div key={benefit.title}><strong>{benefit.title}</strong><span>{benefit.description}</span></div>)}</div></section></main>} /></div>
951
- <Footer adapters={adapters} context={context} />
952
- <FloatingWhatsapp context={context} />
953
- </div>;
2173
+ return (
2174
+ <div
2175
+ className="store-shell nuvler-default-theme"
2176
+ data-theme-id="nuvler-default"
2177
+ data-theme-version="1.0.2"
2178
+ style={style}
2179
+ >
2180
+ <Header adapters={adapters} context={context} />
2181
+ <div className="store-page">
2182
+ <RouteContent
2183
+ adapters={adapters}
2184
+ context={context}
2185
+ route={route}
2186
+ sdk={sdk}
2187
+ home={
2188
+ <main>
2189
+ {sections.map((section, index) => {
2190
+ const Renderer = defaultSectionRegistry[section.type];
2191
+ if (!Renderer) return null;
2192
+ const content = (
2193
+ <Renderer
2194
+ adapters={adapters}
2195
+ context={context}
2196
+ key={`${section.type}-${section.order}-${index}`}
2197
+ sdk={sdk}
2198
+ section={section}
2199
+ />
2200
+ );
2201
+ return section.reference ? (
2202
+ <div
2203
+ id={section.reference}
2204
+ key={`${section.type}-${section.order}-${index}`}
2205
+ style={{ scrollMarginTop: "100px" }}
2206
+ >
2207
+ {content}
2208
+ </div>
2209
+ ) : content;
2210
+ })}
2211
+ <section className="benefits-section">
2212
+ <div className="store-container benefits-grid">
2213
+ {template.benefits.map((benefit) => (
2214
+ <div key={benefit.title}>
2215
+ <strong>{benefit.title}</strong>
2216
+ <span>{benefit.description}</span>
2217
+ </div>
2218
+ ))}
2219
+ </div>
2220
+ </section>
2221
+ </main>
2222
+ }
2223
+ />
2224
+ </div>
2225
+ <Footer adapters={adapters} context={context} />
2226
+ <FloatingWhatsapp context={context} />
2227
+ </div>
2228
+ );
954
2229
  }