@nuvler/cli 0.5.9 → 0.5.10

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.
Files changed (35) hide show
  1. package/README.md +7 -5
  2. package/dist/api/theme-context.js.map +1 -1
  3. package/dist/commands/theme/upgrade.js +2 -1
  4. package/dist/commands/theme/upgrade.js.map +1 -1
  5. package/dist/migrate/generator.js +21 -10
  6. package/dist/migrate/generator.js.map +1 -1
  7. package/dist/migrate/transformer.js +2 -1
  8. package/dist/migrate/transformer.js.map +1 -1
  9. package/dist/nuvler.js +116 -15
  10. package/dist/nuvler.js.map +1 -1
  11. package/dist/templates/nuvler-atelier/nuvler.theme.json +1 -1
  12. package/dist/templates/nuvler-atelier/package.json +1 -1
  13. package/dist/templates/nuvler-atelier/src/definition.tsx +8 -7
  14. package/dist/templates/nuvler-atelier/src/theme.tsx +24 -4
  15. package/dist/templates/nuvler-default/README.md +2 -2
  16. package/dist/templates/nuvler-default/nuvler.theme.json +1 -1
  17. package/dist/templates/nuvler-default/package.json +5 -4
  18. package/dist/templates/nuvler-default/scripts/verify-release.mjs +30 -0
  19. package/dist/templates/nuvler-default/src/header-interactions.tsx +2 -2
  20. package/dist/templates/nuvler-default/src/header.tsx +1 -1
  21. package/dist/templates/nuvler-default/src/home.tsx +13 -2
  22. package/dist/templates/nuvler-default/src/mini-banners.tsx +44 -0
  23. package/dist/templates/nuvler-default/src/product-carousel.tsx +2 -2
  24. package/dist/templates/nuvler-default/src/product-detail-interactive.tsx +7 -2
  25. package/dist/templates/nuvler-default/src/product-detail.tsx +3 -1
  26. package/dist/templates/nuvler-default/src/products.tsx +5 -4
  27. package/dist/templates/nuvler-default/src/theme-component.tsx +18 -4
  28. package/dist/templates/nuvler-default/src/theme.css +58 -0
  29. package/dist/templates/starter/package.json +1 -1
  30. package/dist/templates/starter/src/definition.tsx +5 -5
  31. package/dist/templates/starter/src/theme.tsx +2 -2
  32. package/package.json +2 -2
  33. package/preview-host/package.json +1 -1
  34. package/preview-host/src/fallback-context.json +1 -0
  35. package/preview-host/vendor/theme-runtime/default-theme.tsx +34 -5
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "id": "nuvler-atelier",
4
4
  "name": "Nuvler Atelier",
5
- "version": "0.1.4",
5
+ "version": "0.1.5",
6
6
  "runtimeVersion": "1",
7
7
  "sdkVersion": "^1.3.3",
8
8
  "entry": "src/theme.tsx",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuvler-theme-nuvler-atelier",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -156,14 +156,14 @@ function Footer({ site, pages }: FooterProps) {
156
156
  </footer>;
157
157
  }
158
158
 
159
- function ProductGrid({ products, columns = 3, showCategory = true, showDescription = true }: ProductGridProps) {
159
+ function ProductGrid({ products, columns = 3, showPrices = true, showCategory = true, showDescription = true }: ProductGridProps) {
160
160
  return <div className="atelier-products" data-columns={columns}>{products.map((product, index) => <article className="atelier-product-card" key={product.slug}>
161
161
  <a className="atelier-product-media" href={productUrl(product)}><span className="atelier-product-index">{String(index + 1).padStart(2, "0")}</span><AtelierImage image={product.image} alt={product.title} /></a>
162
162
  <div className="atelier-product-copy">
163
163
  {showCategory && <small>{product.categories[0]?.name || product.brand || "Seleção"}</small>}
164
164
  <h3><a href={productUrl(product)}>{product.title}</a></h3>
165
165
  {showDescription && product.description && <p>{plainText(product.description)}</p>}
166
- <div><span>{price(product) || (product.sku ? `Ref. ${product.sku}` : "Consulte condições")}</span><a href={productUrl(product)} aria-label={`Ver ${product.title}`}>↗</a></div>
166
+ <div>{showPrices && <span>{price(product) || "Preço sob consulta"}</span>}{!showPrices && product.sku && <span>Ref. {product.sku}</span>}<a href={productUrl(product)} aria-label={`Ver ${product.title}`}>↗</a></div>
167
167
  </div>
168
168
  </article>)}</div>;
169
169
  }
@@ -175,6 +175,7 @@ function Home({ sections, products, posts, services, cases, site, template }: Ho
175
175
  const heroButton = value(hero?.data, "buttonLabel") || template.primaryAction(site.modules).label;
176
176
  const heroUrl = value(hero?.data, "buttonUrl") || template.primaryAction(site.modules).href;
177
177
  const highlight = products[0];
178
+ const showPrices = site.settings?.catalog?.showPrices ?? true;
178
179
  const editorial = [...posts, ...cases].slice(0, 3);
179
180
  const bannerSections = sections.filter((section) => section.enabled && section.type === "banner-carousel");
180
181
  return <main>
@@ -183,14 +184,14 @@ function Home({ sections, products, posts, services, cases, site, template }: Ho
183
184
  <div className="atelier-hero-visual">
184
185
  <span className="atelier-orbit" /><span className="atelier-orbit second" />
185
186
  <AtelierImage image={highlight?.image} alt={highlight?.title || heroTitle} />
186
- {highlight && <a href={productUrl(highlight)}><small>Destaque da semana</small><strong>{highlight.title}</strong><span>{price(highlight) || "Conheça o produto"} →</span></a>}
187
+ {highlight && <a href={productUrl(highlight)}><small>Destaque da semana</small><strong>{highlight.title}</strong><span>{showPrices ? price(highlight) || "Conheça o produto" : "Conheça o produto"} →</span></a>}
187
188
  </div>
188
189
  </section>
189
190
  {bannerSections.map((section, index) => <AtelierBannerCarousel section={section} key={section.id || index} />)}
190
191
  <section className="atelier-marquee"><div>{template.benefits.concat(template.benefits).map((benefit, index) => <span key={`${benefit.title}-${index}`}><b>✦</b>{benefit.title}<small>{benefit.description}</small></span>)}</div></section>
191
192
  <section className="atelier-section atelier-container">
192
193
  <header className="atelier-section-heading"><div><span className="atelier-kicker">Seleção essencial</span><h2>Produtos que merecem atenção</h2></div><p>Uma vitrine com mais respiro, imagens protagonistas e as informações certas para decidir.</p><a href="/produtos">Explorar tudo ↗</a></header>
193
- <ProductGrid products={products.slice(0, 6)} columns={3} showCategory={site.settings?.catalog?.showCategory} showDescription={site.settings?.catalog?.showDescription} />
194
+ <ProductGrid products={products.slice(0, 6)} columns={3} showPrices={showPrices} showCategory={site.settings?.catalog?.showCategory} showDescription={site.settings?.catalog?.showDescription} />
194
195
  </section>
195
196
  {services.length > 0 && <section className="atelier-services"><div className="atelier-container"><header><span className="atelier-kicker">Além do catálogo</span><h2>Soluções que acompanham sua escolha.</h2></header><div>{services.slice(0, 4).map((service, index) => <a href={`/servicos/${service.slug}`} key={service.slug}><small>{String(index + 1).padStart(2, "0")}</small><h3>{service.title}</h3><p>{service.description}</p><span>Conhecer solução ↗</span></a>)}</div></div></section>}
196
197
  {editorial.length > 0 && <section className="atelier-section atelier-container"><header className="atelier-section-heading"><div><span className="atelier-kicker">Caderno Nuvler</span><h2>Conteúdo para escolher melhor</h2></div><a href="/blog">Ver publicações ↗</a></header><div className="atelier-editorial-grid">{editorial.map((item, index) => <a href={`${posts.includes(item) ? "/blog" : "/cases"}/${item.slug}`} key={item.slug}><AtelierImage image={item.image || item.thumbnail || item.coverImage} alt={item.title} /><small>Leitura {String(index + 1).padStart(2, "0")}</small><h3>{item.title}</h3><p>{item.description}</p><span>Ler agora ↗</span></a>)}</div></section>}
@@ -198,7 +199,7 @@ function Home({ sections, products, posts, services, cases, site, template }: Ho
198
199
  </main>;
199
200
  }
200
201
 
201
- function ProductDetail({ product, descriptionContent, onAddToCart }: ProductDetailProps) {
202
+ function ProductDetail({ product, showPrices = true, descriptionContent, onAddToCart }: ProductDetailProps) {
202
203
  const initial = useMemo(() => Object.fromEntries(product.variantOptions.map((option) => [option.name, option.values[0] || ""])), [product.variantOptions]);
203
204
  const [selected, setSelected] = useState<Record<string, string>>(initial);
204
205
  const variant = product.variants.find((candidate) => candidate.active && candidate.values.every(({ name, value: optionValue }) => selected[name] === optionValue));
@@ -208,9 +209,9 @@ function ProductDetail({ product, descriptionContent, onAddToCart }: ProductDeta
208
209
  const selectedImage = images.find((image) => image.url === activeImage) || images[0] || null;
209
210
  return <article className="atelier-product-detail">
210
211
  <div className="atelier-gallery"><div className="atelier-gallery-main"><AtelierImage image={selectedImage} alt={product.title} /></div>{images.length > 1 && <div className="atelier-thumbnails">{images.map((image, index) => <button type="button" className={activeImage === image.url ? "active" : ""} onClick={() => setActiveImage(image.url)} key={`${image.url}-${index}`}><AtelierImage image={image} alt={`${product.title} ${index + 1}`} /></button>)}</div>}</div>
211
- <div className="atelier-product-info"><span className="atelier-kicker">{product.categories[0]?.name || product.brand || "Produto selecionado"}</span><h1>{product.title}</h1><div className="atelier-product-meta"><span>{price(product) || "Preço sob consulta"}</span>{(variant?.sku || product.sku) && <small>Ref. {variant?.sku || product.sku}</small>}</div><div className="atelier-description">{descriptionContent}</div>
212
+ <div className="atelier-product-info"><span className="atelier-kicker">{product.categories[0]?.name || product.brand || "Produto selecionado"}</span><h1>{product.title}</h1><div className="atelier-product-meta">{showPrices && <span>{price(product) || "Preço sob consulta"}</span>}{(variant?.sku || product.sku) && <small>Ref. {variant?.sku || product.sku}</small>}</div><div className="atelier-description">{descriptionContent}</div>
212
213
  {product.variantOptions.map((option) => <fieldset key={option.name}><legend>{option.name}: <strong>{selected[option.name]}</strong></legend><div>{option.values.map((optionValue) => <button type="button" className={selected[option.name] === optionValue ? "active" : ""} onClick={() => setSelected((current) => ({ ...current, [option.name]: optionValue }))} key={optionValue}>{optionValue}</button>)}</div></fieldset>)}
213
- <button className="atelier-button atelier-button-dark atelier-add" type="button" disabled={product.variantOptions.length > 0 && !variant} onClick={() => onAddToCart?.({ productSlug: product.slug, productUrl: productUrl(product), title: product.title, sku: variant?.sku || product.sku, variantId: variant?.id, variantName: variant?.name, image: variant?.image || product.image, unitPrice: product.promotionalPrice ?? product.price })}>Adicionar à seleção <b>+</b></button>
214
+ <button className="atelier-button atelier-button-dark atelier-add" type="button" disabled={product.variantOptions.length > 0 && !variant} onClick={() => onAddToCart?.({ productSlug: product.slug, productUrl: productUrl(product), title: product.title, sku: variant?.sku || product.sku, variantId: variant?.id, variantName: variant?.name, image: variant?.image || product.image, unitPrice: showPrices ? product.promotionalPrice ?? product.price : null })}>Adicionar à seleção <b>+</b></button>
214
215
  <div className="atelier-detail-benefits"><span><b>01</b> Atendimento especializado</span><span><b>02</b> Orçamento pelo WhatsApp</span></div>
215
216
  </div>
216
217
  </article>;
@@ -16,6 +16,10 @@ interface CartLine extends ThemeCartItem {
16
16
  quantity: number;
17
17
  }
18
18
 
19
+ function money(value: number): string {
20
+ return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(value);
21
+ }
22
+
19
23
  function catalogHref(route: Extract<ThemeRoute, { type: "catalog" }>, page: number): string {
20
24
  const params = new URLSearchParams();
21
25
  if (route.search) params.set("busca", route.search);
@@ -63,7 +67,10 @@ export default function Theme({ context, route = { type: "home" }, sdk, adapters
63
67
  } as CSSProperties;
64
68
  const [cart, setCart] = useState<CartLine[]>([]);
65
69
  const [cartOpen, setCartOpen] = useState(false);
70
+ const showPrices = site.settings?.catalog?.showPrices ?? true;
66
71
  const cartCount = cart.reduce((total, item) => total + item.quantity, 0);
72
+ const cartTotal = cart.reduce((total, item) => total + (item.unitPrice ?? 0) * item.quantity, 0);
73
+ const hasCompletePrices = cart.length > 0 && cart.every(({ unitPrice }) => typeof unitPrice === "number");
67
74
  const addToCart = (item: ThemeCartItem) => {
68
75
  const key = `${item.productSlug}::${item.variantId || "parent"}`;
69
76
  setCart((current) => {
@@ -75,7 +82,14 @@ export default function Theme({ context, route = { type: "home" }, sdk, adapters
75
82
  sdk?.cart.add(item);
76
83
  setCartOpen(true);
77
84
  };
78
- const message = useMemo(() => `Olá! Gostaria de solicitar um orçamento para:\n\n${cart.map((item, index) => `${index + 1}. ${item.quantity}x ${item.title}${item.variantName ? ` (${item.variantName})` : ""}${item.sku ? ` — ref. ${item.sku}` : ""}`).join("\n\n")}`, [cart]);
85
+ const message = useMemo(() => {
86
+ const lines = cart.map((item, index) => {
87
+ const price = showPrices && typeof item.unitPrice === "number" ? `\nValor unitário: ${money(item.unitPrice)}` : "";
88
+ return `${index + 1}. ${item.quantity}x ${item.title}${item.variantName ? ` (${item.variantName})` : ""}${item.sku ? ` — ref. ${item.sku}` : ""}${price}`;
89
+ });
90
+ const summary = showPrices && hasCompletePrices ? `\n\nTotal estimado: ${money(cartTotal)}` : "";
91
+ return `Olá! Gostaria de solicitar um orçamento para:\n\n${lines.join("\n\n")}${summary}`;
92
+ }, [cart, cartTotal, hasCompletePrices, showPrices]);
79
93
  const whatsapp = site.settings?.contact.whatsapp?.replace(/\D/g, "");
80
94
 
81
95
  let content;
@@ -89,13 +103,13 @@ export default function Theme({ context, route = { type: "home" }, sdk, adapters
89
103
  <form action={route.categoryPath.length ? `/${route.categoryPath.join("/")}` : "/produtos"}><label htmlFor="atelier-catalog-search">Refine sua busca</label><div><input id="atelier-catalog-search" name="busca" defaultValue={route.search} placeholder="Nome, marca ou referência" /><button>↗</button></div></form>
90
104
  {route.facets.map((facet) => <fieldset key={facet.name}><legend>{facet.name}</legend>{facet.values.map(({ value, count }) => { const token = `${facet.name}::${value}`; return <label key={token}><input type="checkbox" name="variante" value={token} defaultChecked={route.variants.includes(token)} /><span>{value}</span><small>{count}</small></label>; })}</fieldset>)}
91
105
  </aside>
92
- <section><ProductGrid products={route.products} columns={site.settings?.catalog?.desktopColumns || 3} showCategory={site.settings?.catalog?.showCategory} showDescription={site.settings?.catalog?.showDescription} />
106
+ <section><ProductGrid products={route.products} columns={site.settings?.catalog?.desktopColumns || 3} showPrices={showPrices} showCategory={site.settings?.catalog?.showCategory} showDescription={site.settings?.catalog?.showDescription} />
93
107
  {route.pagination.totalPages > 1 && <nav className="atelier-pagination" aria-label="Paginação"><a className={!route.pagination.hasPreviousPage ? "disabled" : ""} href={catalogHref(route, route.pagination.page - 1)}>← Anterior</a><span>{route.pagination.page} / {route.pagination.totalPages}</span><a className={!route.pagination.hasNextPage ? "disabled" : ""} href={catalogHref(route, route.pagination.page + 1)}>Próxima →</a></nav>}
94
108
  </section>
95
109
  </div>
96
110
  </main>;
97
111
  } else if (route.type === "product") {
98
- content = <main className="atelier-page atelier-container"><nav className="atelier-breadcrumb"><a href="/">Início</a><span>·</span><a href="/produtos">Produtos</a><span>·</span><strong>{route.product.title}</strong></nav><ProductDetail product={route.product} contact={site.settings?.contact} productUrl={typeof window === "undefined" ? null : window.location.href} descriptionContent={<p>{plainText(route.product.description)}</p>} onAddToCart={addToCart} /></main>;
112
+ content = <main className="atelier-page atelier-container"><nav className="atelier-breadcrumb"><a href="/">Início</a><span>·</span><a href="/produtos">Produtos</a><span>·</span><strong>{route.product.title}</strong></nav><ProductDetail product={route.product} showPrices={showPrices} contact={site.settings?.contact} productUrl={typeof window === "undefined" ? null : window.location.href} descriptionContent={<p>{plainText(route.product.description)}</p>} onAddToCart={addToCart} /></main>;
99
113
  } else if (route.type === "editorial-list") {
100
114
  content = <EditorialList title={route.title} basePath={route.basePath} items={route.items} />;
101
115
  } else if (route.type === "editorial-detail") {
@@ -111,6 +125,12 @@ export default function Theme({ context, route = { type: "home" }, sdk, adapters
111
125
  <Header site={site} categories={context.navigation.categories} pages={context.navigation.pages} menu={context.navigation.menu} headerButton={context.navigation.headerButton} template={themeDefinition.template} searchProducts={adapters?.searchProducts} cart={cartButton} />
112
126
  {content}
113
127
  <Footer site={site} pages={context.navigation.pages} template={themeDefinition.template} />
114
- {cartOpen && <div className="atelier-cart-backdrop" onPointerDown={(event) => event.target === event.currentTarget && setCartOpen(false)}><aside className="atelier-cart-drawer"><header><div><small>Sua curadoria</small><h2>{cartCount} {cartCount === 1 ? "item" : "itens"}</h2></div><button onClick={() => setCartOpen(false)} aria-label="Fechar">×</button></header><div className="atelier-cart-lines">{cart.length === 0 ? <p>Sua seleção está vazia. Explore os produtos e adicione o que interessar.</p> : cart.map((item) => <article key={item.key}><AtelierImage image={item.image} alt={item.title} /><div><strong>{item.title}</strong><small>{item.variantName || item.sku}</small><span><button onClick={() => setCart((current) => current.flatMap((candidate) => candidate.key !== item.key ? [candidate] : candidate.quantity > 1 ? [{ ...candidate, quantity: candidate.quantity - 1 }] : []))}>−</button>{item.quantity}<button onClick={() => setCart((current) => current.map((candidate) => candidate.key === item.key ? { ...candidate, quantity: candidate.quantity + 1 } : candidate))}>+</button></span></div></article>)}</div>{cart.length > 0 && <footer><p>Valores e disponibilidade serão confirmados pela equipe.</p>{whatsapp ? <a className="atelier-button atelier-button-light" href={`https://wa.me/${whatsapp}?text=${encodeURIComponent(message)}`} target="_blank" rel="noreferrer">Enviar pelo WhatsApp ↗</a> : <span>Configure o WhatsApp da loja para concluir.</span>}</footer>}</aside></div>}
128
+ {cartOpen && <div className="atelier-cart-backdrop" onPointerDown={(event) => event.target === event.currentTarget && setCartOpen(false)}>
129
+ <aside className="atelier-cart-drawer">
130
+ <header><div><small>Sua curadoria</small><h2>{cartCount} {cartCount === 1 ? "item" : "itens"}</h2></div><button onClick={() => setCartOpen(false)} aria-label="Fechar">×</button></header>
131
+ <div className="atelier-cart-lines">{cart.length === 0 ? <p>Sua seleção está vazia. Explore os produtos e adicione o que interessar.</p> : cart.map((item) => <article key={item.key}><AtelierImage image={item.image} alt={item.title} /><div><strong>{item.title}</strong><small>{item.variantName || item.sku}</small>{showPrices && typeof item.unitPrice === "number" && <b>{money(item.unitPrice)}</b>}<span><button onClick={() => setCart((current) => current.flatMap((candidate) => candidate.key !== item.key ? [candidate] : candidate.quantity > 1 ? [{ ...candidate, quantity: candidate.quantity - 1 }] : []))}>−</button>{item.quantity}<button onClick={() => setCart((current) => current.map((candidate) => candidate.key === item.key ? { ...candidate, quantity: candidate.quantity + 1 } : candidate))}>+</button></span></div></article>)}</div>
132
+ {cart.length > 0 && <footer>{showPrices && hasCompletePrices && <strong>Total estimado: {money(cartTotal)}</strong>}<p>Valores e disponibilidade serão confirmados pela equipe.</p>{whatsapp ? <a className="atelier-button atelier-button-light" href={`https://wa.me/${whatsapp}?text=${encodeURIComponent(message)}`} target="_blank" rel="noreferrer">Enviar pelo WhatsApp ↗</a> : <span>Configure o WhatsApp da loja para concluir.</span>}</footer>}
133
+ </aside>
134
+ </div>}
115
135
  </div>;
116
136
  }
@@ -65,7 +65,7 @@ Para compilar, gerar o artefato ou publicar, execute na raiz do tooling:
65
65
 
66
66
  ```bash
67
67
  npm run pack:store
68
- npm publish ./artifacts/nuvler-theme-default-1.0.4.tgz --access public
68
+ npm publish ./artifacts/nuvler-theme-default-1.1.2.tgz --access public
69
69
 
70
70
  node packages/cli/dist/nuvler.js theme build --theme themes/nuvler-default
71
71
  npm run pack:theme -- nuvler-default
@@ -73,7 +73,7 @@ node packages/cli/dist/nuvler.js theme publish --theme themes/nuvler-default --o
73
73
  ```
74
74
 
75
75
  O pacote npm contém o renderer local e o CSS. O artefato do Theme Registry é
76
- gerado separadamente como `artifacts/nuvler-default-1.0.4.nuvler-theme.tgz`.
76
+ gerado separadamente como `artifacts/nuvler-default-1.1.2.nuvler-theme.tgz`.
77
77
 
78
78
  Exemplo no App Router:
79
79
 
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "id": "nuvler-default",
4
4
  "name": "Nuvler Default",
5
- "version": "1.0.9",
5
+ "version": "1.1.2",
6
6
  "runtimeVersion": "1",
7
7
  "sdkVersion": "^1.3.3",
8
8
  "entry": "src/theme.tsx",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuvler/theme-default",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Tema padrão oficial da Nuvler",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -54,10 +54,11 @@
54
54
  "scripts": {
55
55
  "dev": "nuvler theme dev --theme .",
56
56
  "validate": "nuvler theme validate --theme .",
57
- "build": "nuvler theme build --theme .",
57
+ "build": "nuvler theme build --theme . && node scripts/verify-release.mjs",
58
58
  "build:package": "node scripts/clean-dist.mjs && tsc -p tsconfig.json && node scripts/copy-assets.mjs",
59
- "pack": "nuvler theme pack --theme .",
60
- "publish:registry": "nuvler theme publish --theme .",
59
+ "pack": "npm run build && nuvler theme pack --theme . --skip-build",
60
+ "publish:registry": "npm run build && nuvler theme publish --theme .",
61
+ "verify:release": "node scripts/verify-release.mjs",
61
62
  "typecheck": "tsc -p tsconfig.json --noEmit"
62
63
  },
63
64
  "peerDependencies": {
@@ -0,0 +1,30 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const themeRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
7
+ const [packageJson, manifest, javascript, stylesheet] = await Promise.all([
8
+ readFile(path.join(themeRoot, "package.json"), "utf8").then(JSON.parse),
9
+ readFile(path.join(themeRoot, "nuvler.theme.json"), "utf8").then(JSON.parse),
10
+ readFile(path.join(themeRoot, "dist", "theme.js"), "utf8"),
11
+ readFile(path.join(themeRoot, "dist", "theme.css"), "utf8"),
12
+ ]);
13
+
14
+ assert.equal(
15
+ manifest.version,
16
+ packageJson.version,
17
+ "A versão do manifesto deve ser igual à versão do pacote do tema.",
18
+ );
19
+ assert.match(
20
+ javascript,
21
+ /mini-banners/,
22
+ "O artefato JavaScript não contém o renderer de mini banners.",
23
+ );
24
+ assert.match(
25
+ stylesheet,
26
+ /\.mini-banners-grid/,
27
+ "O artefato CSS não contém os estilos de mini banners.",
28
+ );
29
+
30
+ console.log(`✓ Release ${manifest.id}@${manifest.version} contém suporte a mini banners.`);
@@ -167,7 +167,7 @@ export function ConfiguredNavigation({ menu, categories: initialCategories, inli
167
167
  return inline ? navigation : <div className="primary-nav-shell">{navigation}</div>;
168
168
  }
169
169
 
170
- export function SmartProductSearch({ endpoint = "/api/product-suggestions", queryParam = "q", searchProducts }: { endpoint?: string; queryParam?: string; searchProducts?: (query: string) => Promise<ThemeProduct[]> }) {
170
+ export function SmartProductSearch({ endpoint = "/api/product-suggestions", queryParam = "q", searchProducts, showPrices = true }: { endpoint?: string; queryParam?: string; searchProducts?: (query: string) => Promise<ThemeProduct[]>; showPrices?: boolean }) {
171
171
  const [value, setValue] = useState("");
172
172
  const [results, setResults] = useState<ThemeProduct[]>([]);
173
173
  const [loading, setLoading] = useState(false);
@@ -267,7 +267,7 @@ export function SmartProductSearch({ endpoint = "/api/product-suggestions", quer
267
267
  {!loading && results.map((product, index) => <a id={`theme-search-result-${index}`} className={activeIndex === index ? "active" : ""} href={productUrl(product)} role="option" aria-selected={activeIndex === index} key={product.slug} onPointerEnter={() => setActiveIndex(index)}>
268
268
  <span className="search-suggestion-image"><ThemeImageView image={product.image} fallbackAlt={product.title} sizes="56px" fallbackWidth={112} fallbackHeight={112} /></span>
269
269
  <span className="search-suggestion-copy"><strong>{product.title}</strong><span className="search-suggestion-meta">{product.categories[0]?.name && <small>{product.categories[0].name}</small>}{product.sku && <small>Ref. {product.sku}</small>}</span></span>
270
- {displayPrice(product) && <b>{displayPrice(product)}</b>}
270
+ {showPrices && displayPrice(product) && <b>{displayPrice(product)}</b>}
271
271
  <span className="search-suggestion-arrow" aria-hidden="true">→</span>
272
272
  </a>)}
273
273
  {!loading && !results.length && <div className="search-suggestions-empty"><strong>Nenhum produto encontrado</strong><p>Tente outro nome, marca ou referência.</p></div>}
@@ -27,5 +27,5 @@ export function Header({ site, categories, menu = [], headerButton, cart, sugges
27
27
  return () => window.removeEventListener("scroll", update);
28
28
  }, []);
29
29
 
30
- return <header className={`store-header${compact ? " is-compact" : ""}`}><div className="store-container header-inner"><MobileStoreMenu site={site} categories={categories} menu={configuredMenu} headerButton={headerButton} /><a className="brand" href="/" aria-label={`${name} — início`}>{site.settings?.logo?.url ? <ThemeImageView image={site.settings.logo} fallbackAlt={name} className="brand-logo" sizes="200px" fallbackWidth={240} fallbackHeight={96} /> : <><span className="brand-mark">7</span><span>{name}</span></>}</a>{configuredMenu.length > 0 && <ConfiguredNavigation inline menu={configuredMenu} categories={categories} />}<div className="header-tools">{site.modules.includes("PRODUCTS") && <SmartProductSearch endpoint={suggestionsEndpoint} queryParam={suggestionsQueryParam} />}{headerButton?.enabled && <a className="header-highlight-link" href={headerButton.href} target={headerButton.openInNewTab ? "_blank" : undefined} rel={headerButton.openInNewTab ? "noopener noreferrer" : undefined} style={{ backgroundColor: headerButton.backgroundColor, color: headerButton.textColor }}>{headerButton.label}</a>}{cart}</div></div></header>;
30
+ return <header className={`store-header${compact ? " is-compact" : ""}`}><div className="store-container header-inner"><MobileStoreMenu site={site} categories={categories} menu={configuredMenu} headerButton={headerButton} /><a className="brand" href="/" aria-label={`${name} — início`}>{site.settings?.logo?.url ? <ThemeImageView image={site.settings.logo} fallbackAlt={name} className="brand-logo" sizes="200px" fallbackWidth={240} fallbackHeight={96} /> : <><span className="brand-mark">7</span><span>{name}</span></>}</a>{configuredMenu.length > 0 && <ConfiguredNavigation inline menu={configuredMenu} categories={categories} />}<div className="header-tools">{site.modules.includes("PRODUCTS") && <SmartProductSearch endpoint={suggestionsEndpoint} queryParam={suggestionsQueryParam} showPrices={site.settings?.catalog?.showPrices ?? true} />}{headerButton?.enabled && <a className="header-highlight-link" href={headerButton.href} target={headerButton.openInNewTab ? "_blank" : undefined} rel={headerButton.openInNewTab ? "noopener noreferrer" : undefined} style={{ backgroundColor: headerButton.backgroundColor, color: headerButton.textColor }}>{headerButton.label}</a>}{cart}</div></div></header>;
31
31
  }
@@ -1,6 +1,7 @@
1
1
  import { useState, type FormEvent } from "react";
2
2
  import type { HomeProps, ThemeContactSubmissionInput, ThemeEditorialItem, ThemeHomeSection, ThemeImage, ThemeSite } from "@nuvler/theme-sdk";
3
3
  import { BannerCarousel, type ThemeBanner } from "./banner-carousel.js";
4
+ import { MiniBanners } from "./mini-banners.js";
4
5
  import { ProductCarousel } from "./product-carousel.js";
5
6
  import { ProductGrid } from "./products.js";
6
7
  import { categoryUrl, ThemeImageView, type ThemeImageComponent } from "./shared.js";
@@ -69,6 +70,15 @@ function banners(data: Record<string, unknown>): ThemeBanner[] {
69
70
  });
70
71
  }
71
72
 
73
+ function miniBanners(data: Record<string, unknown>) {
74
+ return records(data, "items").flatMap((item) => {
75
+ const image = imageValue(item.image);
76
+ const imageUrl = image?.url || text(item, "imageUrl");
77
+ if (!imageUrl) return [];
78
+ return [{ image, imageUrl, imageAlt: text(item, "imageAlt") || undefined, title: text(item, "title") || undefined, link: text(item, "link") || undefined }];
79
+ });
80
+ }
81
+
72
82
  function Heading({ data, href }: { data: Record<string, unknown>; href: string }) {
73
83
  const eyebrow = text(data, "eyebrow");
74
84
  const title = text(data, "title");
@@ -173,6 +183,7 @@ export function Home({ sections, products, posts, services, cases, site, submitC
173
183
  return <>{visible.map((section, index) => {
174
184
  if (section.type === "hero") return <Hero key={section.id || index} section={section} priority={index === 0} ImageComponent={ImageComponent} />;
175
185
  if (section.type === "banner-carousel") return <section className="home-banner-section" key={section.id || index}><BannerCarousel banners={banners(section.data)} autoplay={section.data.autoplay !== false} desktopHeight={typeof section.data.desktopHeight === "number" ? section.data.desktopHeight : undefined} mobileHeight={typeof section.data.mobileHeight === "number" ? section.data.mobileHeight : undefined} imageFit={section.data.imageFit === "CONTAIN" || section.data.imageFit === "NATURAL" ? section.data.imageFit : "COVER"} priority={index === 0} ImageComponent={ImageComponent} /></section>;
186
+ if (section.type === "mini-banners") return <MiniBanners key={section.id || index} layout={section.data.layout === "3x1" ? "3x1" : "2x1"} items={miniBanners(section.data)} ImageComponent={ImageComponent} />;
176
187
  if (section.type === "theme-component") return <ThemeComponent key={section.id || index} section={section} submitContact={submitContact} ImageComponent={ImageComponent} />;
177
188
  if (["image-text", "rich-text", "cta"].includes(section.type)) return <TextSection key={section.id || index} section={section} ImageComponent={ImageComponent} />;
178
189
  if (section.type === "products-grid" || section.type === "products-carousel") {
@@ -186,8 +197,8 @@ export function Home({ sections, products, posts, services, cases, site, submitC
186
197
  ? categoryUrl(matchingPath.slice(0, categoryIndex + 1))
187
198
  : category ? `/produtos?categoria=${encodeURIComponent(category)}` : "/produtos";
188
199
  const productsView = section.type === "products-grid"
189
- ? <ProductGrid products={items} columns={catalog?.desktopColumns} showCategory={catalog?.showCategory} showDescription={catalog?.showDescription} ImageComponent={ImageComponent} />
190
- : <ProductCarousel products={items} showCategory={catalog?.showCategory} showDescription={catalog?.showDescription} ImageComponent={ImageComponent} />;
200
+ ? <ProductGrid products={items} columns={catalog?.desktopColumns} showPrices={catalog?.showPrices} showCategory={catalog?.showCategory} showDescription={catalog?.showDescription} ImageComponent={ImageComponent} />
201
+ : <ProductCarousel products={items} showPrices={catalog?.showPrices} showCategory={catalog?.showCategory} showDescription={catalog?.showDescription} ImageComponent={ImageComponent} />;
191
202
  return <section className="store-section home-products-section" data-layout={section.type === "products-carousel" ? "carousel" : "grid"} key={section.id || index}><div className="store-container"><Heading data={section.data} href={allProductsHref} />{productsView}</div></section>;
192
203
  }
193
204
  const map = section.type === "services-grid" ? { items: services, path: "/servicos" } : section.type === "cases-grid" ? { items: cases, path: "/cases" } : { items: posts, path: "/blog" };
@@ -0,0 +1,44 @@
1
+ import type { ThemeImage, ThemeMiniBannerItem, ThemeMiniBannersLayout } from "@nuvler/theme-sdk";
2
+ import { ThemeImageView, type ThemeImageComponent } from "./shared.js";
3
+
4
+ function itemImage(item: ThemeMiniBannerItem): ThemeImage | null {
5
+ if (item.image?.url) return item.image;
6
+ if (!item.imageUrl) return null;
7
+ return {
8
+ url: item.imageUrl,
9
+ alt: item.imageAlt || item.title || "Mini banner",
10
+ width: null,
11
+ height: null,
12
+ };
13
+ }
14
+
15
+ function MiniBanner({ item, ImageComponent }: { item: ThemeMiniBannerItem; ImageComponent: ThemeImageComponent }) {
16
+ const image = itemImage(item);
17
+ if (!image) return null;
18
+ const content = (
19
+ <>
20
+ <span className="mini-banner-image">
21
+ <ImageComponent image={image} fallbackAlt={item.title || "Mini banner"} sizes="(max-width: 800px) 100vw, 50vw" fallbackWidth={800} fallbackHeight={450} />
22
+ </span>
23
+ {item.title && <strong>{item.title}</strong>}
24
+ </>
25
+ );
26
+ return item.link
27
+ ? <a className="mini-banner-card" href={item.link}>{content}</a>
28
+ : <div className="mini-banner-card">{content}</div>;
29
+ }
30
+
31
+ export function MiniBanners({ layout, items, ImageComponent = ThemeImageView }: {
32
+ layout: ThemeMiniBannersLayout;
33
+ items: ThemeMiniBannerItem[];
34
+ ImageComponent?: ThemeImageComponent;
35
+ }) {
36
+ if (!items.length) return null;
37
+ return (
38
+ <section className="store-section mini-banners-section">
39
+ <div className="store-container mini-banners-grid" data-layout={layout}>
40
+ {items.map((item, index) => <MiniBanner key={`${item.image?.url || item.imageUrl || "mini-banner"}-${index}`} item={item} ImageComponent={ImageComponent} />)}
41
+ </div>
42
+ </section>
43
+ );
44
+ }
@@ -4,13 +4,13 @@ import { ProductCarouselFrame } from "./carousel-frame.js";
4
4
  import { ProductCard } from "./products.js";
5
5
  import type { ThemeImageComponent } from "./shared.js";
6
6
 
7
- export function ProductCarousel({ products, showCategory, showDescription, ImageComponent }: { products: ThemeProduct[]; showCategory?: boolean; showDescription?: boolean; ImageComponent?: ThemeImageComponent }) {
7
+ export function ProductCarousel({ products, showPrices = true, showCategory, showDescription, ImageComponent }: { products: ThemeProduct[]; showPrices?: boolean; showCategory?: boolean; showDescription?: boolean; ImageComponent?: ThemeImageComponent }) {
8
8
  if (!products.length) return <div className="empty-state"><span>7</span><h2>Nenhum produto encontrado</h2><p>Escolha outra categoria ou publique produtos para esta vitrine.</p></div>;
9
9
  return (
10
10
  <ProductCarouselFrame>
11
11
  {products.map((product) => (
12
12
  <div className="product-carousel-item" key={product.slug}>
13
- <ProductCard product={product} showCategory={showCategory} showDescription={showDescription} ImageComponent={ImageComponent} />
13
+ <ProductCard product={product} showPrices={showPrices} showCategory={showCategory} showDescription={showDescription} ImageComponent={ImageComponent} />
14
14
  </div>
15
15
  ))}
16
16
  </ProductCarouselFrame>
@@ -70,6 +70,7 @@ interface ProductDetailInteractiveProps extends Omit<ProductDetailProps, "descri
70
70
 
71
71
  export function ProductDetailInteractive({
72
72
  product,
73
+ showPrices = true,
73
74
  contact,
74
75
  productUrl,
75
76
  onAddToCart,
@@ -114,7 +115,11 @@ export function ProductDetailInteractive({
114
115
  const selectedImage = images.find((image) => image.url === imageUrl) || images[0] || product.image;
115
116
  const phone = contact?.whatsapp?.replace(/\D/g, "");
116
117
  const variantDescription = variant?.values.map(({ name, value }) => `${name}: ${value}`).join(", ") || "";
117
- const message = `Olá! Gostaria de solicitar um orçamento para ${product.title}${variantDescription ? ` (${variantDescription})` : ""}${variant?.sku ? ` — ref. ${variant.sku}` : ""}.${productUrl ? ` ${productUrl}` : ""}`;
118
+ const unitPrice = variant ? null : product.promotionalPrice ?? product.price;
119
+ const priceText = showPrices && typeof unitPrice === "number"
120
+ ? ` Valor: ${new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(unitPrice)}.`
121
+ : "";
122
+ const message = `Olá! Gostaria de solicitar um orçamento para ${product.title}${variantDescription ? ` (${variantDescription})` : ""}${variant?.sku ? ` — ref. ${variant.sku}` : ""}.${priceText}${productUrl ? ` ${productUrl}` : ""}`;
118
123
  const whatsapp = phone ? `https://wa.me/${phone}?text=${encodeURIComponent(message)}` : null;
119
124
  const hasVariants = product.variantOptions.length > 0;
120
125
  const outOfStock = product.stockQuantity === 0;
@@ -253,7 +258,7 @@ export function ProductDetailInteractive({
253
258
  variantId: variant?.id,
254
259
  variantName: variantDescription,
255
260
  image: variant?.image || product.image,
256
- unitPrice: variant ? null : product.promotionalPrice ?? product.price,
261
+ unitPrice: showPrices ? unitPrice : null,
257
262
  })}
258
263
  >Adicionar ao orçamento</button>}
259
264
  {canPurchase && whatsapp && <a className={`button ${addToCart ? "button-secondary" : "button-primary"} button-block`} href={whatsapp} target="_blank" rel="noreferrer">Orçar somente este item</a>}
@@ -10,6 +10,7 @@ function discountPercent(price: number | null, promotionalPrice: number | null)
10
10
 
11
11
  export function ProductDetail({
12
12
  product,
13
+ showPrices = true,
13
14
  contact,
14
15
  productUrl,
15
16
  descriptionContent,
@@ -84,7 +85,7 @@ export function ProductDetail({
84
85
  const information = <>
85
86
  {product.categories[0] && <span className="product-category">{product.categories[0].name}</span>}
86
87
  <h1>{product.title}</h1>
87
- <div className="product-price-block">{previousPrice && <s>{previousPrice}</s>}{currentPrice ? <strong>{currentPrice}</strong> : <span>Consulte condições com a loja</span>}{discount && <small>{discount}% de desconto</small>}</div>
88
+ {showPrices && <div className="product-price-block">{previousPrice && <s>{previousPrice}</s>}{currentPrice ? <strong>{currentPrice}</strong> : <span>Consulte condições com a loja</span>}{discount && <small>{discount}% de desconto</small>}</div>}
88
89
  {stockLabel && <p className={`product-availability${product.stockQuantity === 0 ? " unavailable" : ""}`}>{stockLabel}</p>}
89
90
  {product.sku && <p className="product-reference">Ref. {product.sku}</p>}
90
91
  <div className="product-description">{descriptionContent}</div>
@@ -95,6 +96,7 @@ export function ProductDetail({
95
96
  return (
96
97
  <ProductDetailInteractive
97
98
  product={product}
99
+ showPrices={showPrices}
98
100
  contact={contact}
99
101
  productUrl={productUrl}
100
102
  onAddToCart={onAddToCart}
@@ -7,8 +7,9 @@ function discountPercent(price: number | null, promotionalPrice: number | null)
7
7
  return Math.round((1 - promotionalPrice / price) * 100);
8
8
  }
9
9
 
10
- export function ProductCard({ product, showCategory = true, showDescription = true, ImageComponent = ThemeImageView }: {
10
+ export function ProductCard({ product, showPrices = true, showCategory = true, showDescription = true, ImageComponent = ThemeImageView }: {
11
11
  product: ThemeProduct;
12
+ showPrices?: boolean;
12
13
  showCategory?: boolean;
13
14
  showDescription?: boolean;
14
15
  ImageComponent?: ThemeImageComponent;
@@ -20,10 +21,10 @@ export function ProductCard({ product, showCategory = true, showDescription = tr
20
21
  const previousPrice = product.promotionalPrice !== null && product.price !== null && product.promotionalPrice < product.price
21
22
  ? displayPrice({ ...product, promotionalPrice: null })
22
23
  : null;
23
- return <article className="product-card" data-unavailable={unavailable || undefined}><a className="product-card-image" href={href} aria-label={`Ver ${product.title}`}>{discount && <span className="product-card-badge">-{discount}%</span>}{unavailable && <span className="product-card-stock">Indisponível</span>}<ImageComponent image={product.image} fallbackAlt={product.title} sizes="(max-width: 720px) 92vw, (max-width: 1100px) 45vw, 25vw" fallbackWidth={720} fallbackHeight={720} /></a><div className="product-card-content">{showCategory && <span className={`product-category${product.categories[0] ? "" : " product-category-empty"}`}>{product.categories[0]?.name || "Sem categoria"}</span>}<h3><a className="product-card-details-link" href={href}>{product.title}</a></h3>{showDescription && product.description && <p className="product-card-description">{plainText(product.description)}</p>}<div className="product-card-price">{previousPrice && <s>{previousPrice}</s>}{currentPrice ? <strong>{currentPrice}</strong> : <span>Consulte condições</span>}</div>{product.sku && <small className="product-card-sku">Ref. {product.sku}</small>}<ProductCardAction href={href} hasVariants={product.variantOptions.length > 0} unavailable={unavailable} item={{ productSlug: product.slug, productUrl: href, title: product.title, sku: product.sku, image: product.image, unitPrice: product.promotionalPrice ?? product.price }} /></div></article>;
24
+ return <article className="product-card" data-unavailable={unavailable || undefined}><a className="product-card-image" href={href} aria-label={`Ver ${product.title}`}>{showPrices && discount && <span className="product-card-badge">-{discount}%</span>}{unavailable && <span className="product-card-stock">Indisponível</span>}<ImageComponent image={product.image} fallbackAlt={product.title} sizes="(max-width: 720px) 92vw, (max-width: 1100px) 45vw, 25vw" fallbackWidth={720} fallbackHeight={720} /></a><div className="product-card-content">{showCategory && <span className={`product-category${product.categories[0] ? "" : " product-category-empty"}`}>{product.categories[0]?.name || "Sem categoria"}</span>}<h3><a className="product-card-details-link" href={href}>{product.title}</a></h3>{showDescription && product.description && <p className="product-card-description">{plainText(product.description)}</p>}{showPrices && <div className="product-card-price">{previousPrice && <s>{previousPrice}</s>}{currentPrice ? <strong>{currentPrice}</strong> : <span>Consulte condições</span>}</div>}{product.sku && <small className="product-card-sku">Ref. {product.sku}</small>}<ProductCardAction href={href} hasVariants={product.variantOptions.length > 0} unavailable={unavailable} item={{ productSlug: product.slug, productUrl: href, title: product.title, sku: product.sku, image: product.image, unitPrice: showPrices ? product.promotionalPrice ?? product.price : null }} /></div></article>;
24
25
  }
25
26
 
26
- export function ProductGrid({ products, columns = 4, showCategory = true, showDescription = true, ImageComponent = ThemeImageView }: ProductGridProps & { ImageComponent?: ThemeImageComponent }) {
27
+ export function ProductGrid({ products, columns = 4, showPrices = true, showCategory = true, showDescription = true, ImageComponent = ThemeImageView }: ProductGridProps & { ImageComponent?: ThemeImageComponent }) {
27
28
  if (!products.length) return <div className="empty-state"><span>7</span><h2>Nenhum produto encontrado</h2><p>Novos itens aparecerão aqui assim que forem publicados.</p></div>;
28
- return <div className="product-grid" data-columns={columns}>{products.map((product) => <ProductCard key={product.slug} product={product} showCategory={showCategory} showDescription={showDescription} ImageComponent={ImageComponent} />)}</div>;
29
+ return <div className="product-grid" data-columns={columns}>{products.map((product) => <ProductCard key={product.slug} product={product} showPrices={showPrices} showCategory={showCategory} showDescription={showDescription} ImageComponent={ImageComponent} />)}</div>;
29
30
  }
@@ -34,6 +34,10 @@ interface PreviewCartItem extends ThemeCartItem {
34
34
  quantity: number;
35
35
  }
36
36
 
37
+ function money(value: number): string {
38
+ return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(value);
39
+ }
40
+
37
41
  function catalogHref(route: Extract<PreviewRoute, { type: "catalog" }>, page: number): string {
38
42
  const params = new URLSearchParams();
39
43
  if (route.search) params.set("busca", route.search);
@@ -93,8 +97,18 @@ export function createNuvlerDefaultRuntime(themeDefinition: NuvlerStoreThemeDefi
93
97
  "--container-width": `${containerWidth}px`,
94
98
  "--border-radius": `${borderRadius}px`,
95
99
  } as CSSProperties;
100
+ const showPrices = site.settings?.catalog?.showPrices ?? true;
96
101
  const cartCount = cartItems.reduce((total, item) => total + item.quantity, 0);
97
- const cartMessage = useMemo(() => `Olá! Gostaria de solicitar um orçamento para os itens abaixo:\n\n${cartItems.map((item, index) => `${index + 1}. ${item.quantity}x ${item.title}${item.variantName ? ` (${item.variantName})` : ""}${item.sku ? ` — ref. ${item.sku}` : ""}`).join("\n\n")}`, [cartItems]);
102
+ const cartTotal = cartItems.reduce((total, item) => total + (item.unitPrice ?? 0) * item.quantity, 0);
103
+ const hasCompletePrices = cartItems.length > 0 && cartItems.every(({ unitPrice }) => typeof unitPrice === "number");
104
+ const cartMessage = useMemo(() => {
105
+ const lines = cartItems.map((item, index) => {
106
+ const price = showPrices && typeof item.unitPrice === "number" ? `\nValor unitário: ${money(item.unitPrice)}` : "";
107
+ return `${index + 1}. ${item.quantity}x ${item.title}${item.variantName ? ` (${item.variantName})` : ""}${item.sku ? ` — ref. ${item.sku}` : ""}${price}`;
108
+ });
109
+ const summary = showPrices && hasCompletePrices ? `\n\nTotal estimado: ${money(cartTotal)}` : "";
110
+ return `Olá! Gostaria de solicitar um orçamento para os itens abaixo:\n\n${lines.join("\n\n")}${summary}`;
111
+ }, [cartItems, cartTotal, hasCompletePrices, showPrices]);
98
112
  const whatsapp = site.settings?.contact.whatsapp?.replace(/\D/g, "");
99
113
  const checkoutUrl = whatsapp && cartItems.length
100
114
  ? `https://wa.me/${whatsapp}?text=${encodeURIComponent(cartMessage)}`
@@ -111,15 +125,15 @@ export function createNuvlerDefaultRuntime(themeDefinition: NuvlerStoreThemeDefi
111
125
  const cartButton = <button type="button" className="cart-button" onClick={() => setCartOpen(true)} aria-label={`Abrir carrinho com ${cartCount} itens`}><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 4h2l2 11h10l2-8H6M9 20h.01M17 20h.01" /></svg>{cartCount > 0 && <span>{Math.min(cartCount, 99)}</span>}</button>;
112
126
  let content;
113
127
  if (route.type === "home") content = <main><Home sections={context.home.content.sections} products={context.catalog.products} posts={context.editorial.posts} services={context.editorial.services} cases={context.editorial.cases} site={site} submitContact={sdk?.contact?.submit} template={themeDefinition.template} /></main>;
114
- else if (route.type === "product") content = <main className="product-page"><div className="store-container"><nav className="breadcrumbs" aria-label="Navegação estrutural"><a href="/">Início</a><span>/</span><a href="/produtos">Produtos</a><span>/</span><strong>{route.product.title}</strong></nav><ProductDetail product={route.product} contact={site.settings?.contact} productUrl={window.location.href} descriptionContent={<p>{plainText(route.product.description)}</p>} onAddToCart={addToCart} /></div></main>;
115
- else if (route.type === "catalog") content = <main className="catalog-page"><section className="catalog-hero"><div className="store-container"><span>Nosso catálogo</span><h1>{route.search ? `Busca por “${route.search}”` : "Todos os produtos"}</h1><p>{route.pagination.total} produto(s)</p></div></section><div className="store-container catalog-layout"><aside className="category-filter catalog-filters"><form action={route.categoryPath.length ? `/${route.categoryPath.join("/")}` : "/produtos"} className="catalog-filter-form"><label htmlFor="preview-catalog-search">Buscar no catálogo</label><div className="catalog-filter-search"><input id="preview-catalog-search" name="busca" type="search" defaultValue={route.search} placeholder="Nome do produto" /><button type="submit" aria-label="Pesquisar">⌕</button></div></form>{route.facets.length > 0 && <form className="catalog-variant-filters">{route.search && <input type="hidden" name="busca" value={route.search} />}{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>)}<button type="submit" className="button button-primary button-block">Aplicar filtros</button></form>}</aside><section className="catalog-results"><ProductGrid products={route.products} columns={site.settings?.catalog?.desktopColumns || 3} showCategory={site.settings?.catalog?.showCategory} showDescription={site.settings?.catalog?.showDescription} />{route.pagination.totalPages > 1 && <nav className="catalog-pagination" aria-label="Paginação dos produtos"><a className={route.pagination.hasPreviousPage ? "" : "disabled"} href={catalogHref(route, Math.max(1, route.pagination.page - 1))}><span>‹</span> Anterior</a><div className="catalog-pagination-pages"><span className="catalog-pagination-item"><a className="active" href={catalogHref(route, route.pagination.page)}>{route.pagination.page}</a></span></div><a className={route.pagination.hasNextPage ? "" : "disabled"} href={catalogHref(route, Math.min(route.pagination.totalPages, route.pagination.page + 1))}>Próxima <span>›</span></a></nav>}</section></div></main>;
128
+ else if (route.type === "product") content = <main className="product-page"><div className="store-container"><nav className="breadcrumbs" aria-label="Navegação estrutural"><a href="/">Início</a><span>/</span><a href="/produtos">Produtos</a><span>/</span><strong>{route.product.title}</strong></nav><ProductDetail product={route.product} showPrices={showPrices} contact={site.settings?.contact} productUrl={window.location.href} descriptionContent={<p>{plainText(route.product.description)}</p>} onAddToCart={addToCart} /></div></main>;
129
+ else if (route.type === "catalog") content = <main className="catalog-page"><section className="catalog-hero"><div className="store-container"><span>Nosso catálogo</span><h1>{route.search ? `Busca por “${route.search}”` : "Todos os produtos"}</h1><p>{route.pagination.total} produto(s)</p></div></section><div className="store-container catalog-layout"><aside className="category-filter catalog-filters"><form action={route.categoryPath.length ? `/${route.categoryPath.join("/")}` : "/produtos"} className="catalog-filter-form"><label htmlFor="preview-catalog-search">Buscar no catálogo</label><div className="catalog-filter-search"><input id="preview-catalog-search" name="busca" type="search" defaultValue={route.search} placeholder="Nome do produto" /><button type="submit" aria-label="Pesquisar">⌕</button></div></form>{route.facets.length > 0 && <form className="catalog-variant-filters">{route.search && <input type="hidden" name="busca" value={route.search} />}{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>)}<button type="submit" className="button button-primary button-block">Aplicar filtros</button></form>}</aside><section className="catalog-results"><ProductGrid products={route.products} columns={site.settings?.catalog?.desktopColumns || 3} showPrices={showPrices} showCategory={site.settings?.catalog?.showCategory} showDescription={site.settings?.catalog?.showDescription} />{route.pagination.totalPages > 1 && <nav className="catalog-pagination" aria-label="Paginação dos produtos"><a className={route.pagination.hasPreviousPage ? "" : "disabled"} href={catalogHref(route, Math.max(1, route.pagination.page - 1))}><span>‹</span> Anterior</a><div className="catalog-pagination-pages"><span className="catalog-pagination-item"><a className="active" href={catalogHref(route, route.pagination.page)}>{route.pagination.page}</a></span></div><a className={route.pagination.hasNextPage ? "" : "disabled"} href={catalogHref(route, Math.min(route.pagination.totalPages, route.pagination.page + 1))}>Próxima <span>›</span></a></nav>}</section></div></main>;
116
130
  else if (route.type === "editorial-list") { const meta = editorialMeta(route.basePath); content = <main className="editorial-list-page"><section className="theme-page-hero"><div className="store-container"><span className="page-kicker">{meta.eyebrow}</span><h1>{route.title}</h1></div></section><section className="store-section"><div className="store-container"><EditorialPreview items={route.items} basePath={route.basePath} /></div></section></main>; }
117
131
  else if (route.type === "editorial-detail") { const meta = editorialMeta(route.basePath); const image = route.item.image || route.item.coverImage || route.item.thumbnail; content = <main className="article-page"><article className="store-container article-shell"><nav className="breadcrumbs" aria-label="Navegação estrutural"><a href="/">Início</a><span>/</span><a href={route.basePath}>{route.basePath === "/blog" ? "Blog" : route.basePath === "/servicos" ? "Serviços" : "Cases"}</a><span>/</span><strong>{route.item.title}</strong></nav><header className="article-header">{(route.item.category?.title || route.item.category?.name) ? <span>{route.item.category.title || route.item.category.name}</span> : <span>{meta.eyebrow}</span>}<h1>{route.item.title}</h1>{route.item.description && <p>{route.item.description}</p>}{publishedDate(route.item.publishedAt) && <small>{publishedDate(route.item.publishedAt)}</small>}</header>{image && <ThemeImageView image={image} fallbackAlt={route.item.title} className="article-cover" priority sizes="(max-width: 1100px) 100vw, 1040px" fallbackWidth={1600} fallbackHeight={900} />}<div className="article-content"><a className="text-link" href={route.basePath}>← Voltar para {route.basePath === "/blog" ? "o blog" : route.basePath === "/servicos" ? "serviços" : "cases"}</a></div></article></main>; }
118
132
  else if (route.type === "not-found") content = NotFound ? <NotFound homeHref="/" /> : <main className="not-found-page"><div className="not-found-card"><span>404</span><h1>Conteúdo não encontrado</h1></div></main>;
119
133
  else content = <main className="not-found-page"><div className="not-found-card"><span>Carregando</span><h1>{route.title || "Buscando conteúdo da loja"}</h1></div></main>;
120
134
  // A 404 mantém a mesma moldura das demais páginas, inclusive o footer.
121
135
  const isNotFound = false;
122
- return <ThemeInteractionProvider onAddToCart={addToCart}><div className="store-shell nuvler-default-theme" data-theme-id={themeDefinition.manifest.id} data-theme-version={themeDefinition.manifest.version} style={style}><Header site={site} categories={context.navigation.categories} pages={context.navigation.pages} menu={context.navigation.menu} headerButton={context.navigation.headerButton} template={themeDefinition.template} searchProducts={adapters?.searchProducts} cart={cartButton} /><div className={`store-page${isNotFound ? " store-page-not-found" : ""}`}>{content}</div>{!isNotFound && <Footer site={site} pages={context.navigation.pages} template={themeDefinition.template} />}{cartOpen && <div className="cart-backdrop" role="presentation" onPointerDown={(event) => event.target === event.currentTarget && setCartOpen(false)}><aside className="cart-drawer" aria-label="Carrinho de orçamento"><div className="cart-heading"><div><small>Seu orçamento</small><strong>{cartCount} {cartCount === 1 ? "item" : "itens"}</strong></div><button type="button" onClick={() => setCartOpen(false)} aria-label="Fechar carrinho">×</button></div><div className="cart-items">{!cartItems.length && <div className="cart-empty"><strong>Seu carrinho está vazio</strong><p>Abra um produto e adicione-o para montar a solicitação.</p><button type="button" onClick={() => setCartOpen(false)}>Continuar navegando</button></div>}{cartItems.map((item) => <article className="cart-item" key={item.key}><a href={item.productUrl || productUrl({ slug: item.productSlug })} onClick={() => setCartOpen(false)}><ThemeImageView image={item.image} fallbackAlt={item.title} /></a><div><strong>{item.title}</strong>{item.variantName && <small>{item.variantName}</small>}{item.sku && <small>Ref. {item.sku}</small>}<div className="cart-quantity"><button type="button" onClick={() => setCartItems((current) => current.flatMap((candidate) => candidate.key !== item.key ? [candidate] : candidate.quantity > 1 ? [{ ...candidate, quantity: candidate.quantity - 1 }] : []))}>−</button><span>{item.quantity}</span><button type="button" onClick={() => setCartItems((current) => current.map((candidate) => candidate.key === item.key ? { ...candidate, quantity: Math.min(99, candidate.quantity + 1) } : candidate))}>+</button><button type="button" className="cart-remove" onClick={() => setCartItems((current) => current.filter((candidate) => candidate.key !== item.key))}>Remover</button></div></div></article>)}</div>{cartItems.length > 0 && <footer className="cart-footer"><p>O valor e a disponibilidade serão confirmados pela loja.</p>{checkoutUrl ? <a className="button button-primary button-block" href={checkoutUrl} target="_blank" rel="noreferrer">Enviar orçamento pelo WhatsApp</a> : <p className="cart-warning">Configure o WhatsApp da loja para enviar o orçamento.</p>}</footer>}</aside></div>}</div></ThemeInteractionProvider>;
136
+ return <ThemeInteractionProvider onAddToCart={addToCart}><div className="store-shell nuvler-default-theme" data-theme-id={themeDefinition.manifest.id} data-theme-version={themeDefinition.manifest.version} style={style}><Header site={site} categories={context.navigation.categories} pages={context.navigation.pages} menu={context.navigation.menu} headerButton={context.navigation.headerButton} template={themeDefinition.template} searchProducts={adapters?.searchProducts} cart={cartButton} /><div className={`store-page${isNotFound ? " store-page-not-found" : ""}`}>{content}</div>{!isNotFound && <Footer site={site} pages={context.navigation.pages} template={themeDefinition.template} />}{cartOpen && <div className="cart-backdrop" role="presentation" onPointerDown={(event) => event.target === event.currentTarget && setCartOpen(false)}><aside className="cart-drawer" aria-label="Carrinho de orçamento"><div className="cart-heading"><div><small>Seu orçamento</small><strong>{cartCount} {cartCount === 1 ? "item" : "itens"}</strong></div><button type="button" onClick={() => setCartOpen(false)} aria-label="Fechar carrinho">×</button></div><div className="cart-items">{!cartItems.length && <div className="cart-empty"><strong>Seu carrinho está vazio</strong><p>Abra um produto e adicione-o para montar a solicitação.</p><button type="button" onClick={() => setCartOpen(false)}>Continuar navegando</button></div>}{cartItems.map((item) => <article className="cart-item" key={item.key}><a href={item.productUrl || productUrl({ slug: item.productSlug })} onClick={() => setCartOpen(false)}><ThemeImageView image={item.image} fallbackAlt={item.title} /></a><div><strong>{item.title}</strong>{item.variantName && <small>{item.variantName}</small>}{item.sku && <small>Ref. {item.sku}</small>}{showPrices && typeof item.unitPrice === "number" && <b>{money(item.unitPrice)}</b>}<div className="cart-quantity"><button type="button" onClick={() => setCartItems((current) => current.flatMap((candidate) => candidate.key !== item.key ? [candidate] : candidate.quantity > 1 ? [{ ...candidate, quantity: candidate.quantity - 1 }] : []))}>−</button><span>{item.quantity}</span><button type="button" onClick={() => setCartItems((current) => current.map((candidate) => candidate.key === item.key ? { ...candidate, quantity: Math.min(99, candidate.quantity + 1) } : candidate))}>+</button><button type="button" className="cart-remove" onClick={() => setCartItems((current) => current.filter((candidate) => candidate.key !== item.key))}>Remover</button></div></div></article>)}</div>{cartItems.length > 0 && <footer className="cart-footer">{showPrices && hasCompletePrices && <div><span>Total estimado</span><strong>{money(cartTotal)}</strong></div>}<p>O valor e a disponibilidade serão confirmados pela loja.</p>{checkoutUrl ? <a className="button button-primary button-block" href={checkoutUrl} target="_blank" rel="noreferrer">Enviar orçamento pelo WhatsApp</a> : <p className="cart-warning">Configure o WhatsApp da loja para enviar o orçamento.</p>}</footer>}</aside></div>}</div></ThemeInteractionProvider>;
123
137
  }
124
138
 
125
139
  Theme.displayName = `NuvlerThemeRuntime(${themeDefinition.manifest.id})`;