@nuvler/cli 0.4.2 → 0.4.4

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 (40) hide show
  1. package/README.md +225 -0
  2. package/dist/commands/theme/create.js +6 -4
  3. package/dist/commands/theme/create.js.map +1 -1
  4. package/dist/commands/theme/upgrade.js +128 -0
  5. package/dist/commands/theme/upgrade.js.map +1 -0
  6. package/dist/index.js +39 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/migrate/analyzer.js +147 -11
  9. package/dist/migrate/analyzer.js.map +1 -1
  10. package/dist/migrate/classifier.js +10 -6
  11. package/dist/migrate/classifier.js.map +1 -1
  12. package/dist/migrate/generator.js +8 -6
  13. package/dist/migrate/generator.js.map +1 -1
  14. package/dist/migrate/transformer.js +150 -27
  15. package/dist/migrate/transformer.js.map +1 -1
  16. package/dist/nuvler.js +462 -58
  17. package/dist/nuvler.js.map +1 -1
  18. package/dist/templates/nuvler-atelier/README.md +1 -1
  19. package/dist/templates/nuvler-atelier/nuvler.theme.json +2 -2
  20. package/dist/templates/nuvler-atelier/package.json +4 -3
  21. package/dist/templates/nuvler-atelier/src/definition.tsx +10 -9
  22. package/dist/templates/nuvler-atelier/src/theme.tsx +2 -2
  23. package/dist/templates/nuvler-default/README.md +2 -2
  24. package/dist/templates/nuvler-default/nuvler.theme.json +2 -2
  25. package/dist/templates/nuvler-default/package.json +3 -3
  26. package/dist/templates/nuvler-default/src/header-interactions.tsx +113 -11
  27. package/dist/templates/nuvler-default/src/header.tsx +6 -4
  28. package/dist/templates/nuvler-default/src/home.tsx +22 -5
  29. package/dist/templates/nuvler-default/src/product-detail-interactive.tsx +32 -1
  30. package/dist/templates/nuvler-default/src/products.tsx +4 -2
  31. package/dist/templates/nuvler-default/src/server-shell.tsx +4 -1
  32. package/dist/templates/nuvler-default/src/shared.tsx +3 -7
  33. package/dist/templates/nuvler-default/src/theme-component.tsx +6 -5
  34. package/dist/templates/nuvler-default/src/theme.css +138 -2
  35. package/dist/templates/starter/nuvler.theme.json +1 -1
  36. package/dist/templates/starter/package.json +3 -2
  37. package/dist/templates/starter/src/definition.tsx +3 -2
  38. package/package.json +2 -2
  39. package/preview-host/package.json +1 -1
  40. package/preview-host/vendor/theme-runtime/default-theme.tsx +13 -12
@@ -1,5 +1,5 @@
1
1
  import type { ComponentType } from "react";
2
- import type { ThemeImage, ThemeProduct } from "@nuvler/theme-sdk";
2
+ import { htmlToPlainText, type ThemeImage, type ThemeProduct } from "@nuvler/theme-sdk";
3
3
 
4
4
  export interface ThemeImageViewProps {
5
5
  image: ThemeImage | null | undefined;
@@ -41,11 +41,7 @@ export function ThemeImageView({
41
41
  }
42
42
 
43
43
  export function plainText(value: string): string {
44
- return value
45
- .replace(/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi, " ")
46
- .replace(/<[^>]+>/g, " ")
47
- .replace(/\s+/g, " ")
48
- .trim();
44
+ return htmlToPlainText(value);
49
45
  }
50
46
 
51
47
  export function displayPrice(product: ThemeProduct): string | null {
@@ -56,5 +52,5 @@ export function displayPrice(product: ThemeProduct): string | null {
56
52
  }
57
53
 
58
54
  export function categoryUrl(path: string[]): string {
59
- return `/categoria/${path.map(encodeURIComponent).join("/")}`;
55
+ return `/${path.map(encodeURIComponent).join("/")}`;
60
56
  }
@@ -1,14 +1,15 @@
1
1
  "use client";
2
2
 
3
3
  import { useMemo, useState, type CSSProperties } from "react";
4
- import type { NuvlerStoreThemeDefinition, ThemeCartItem, ThemeCategory, ThemeEditorialItem, ThemeHomeSection, ThemePageSummary, ThemeProduct, ThemeRuntimeAdapters, ThemeSite } from "@nuvler/theme-sdk";
4
+ import { productUrl, type NuvlerStoreThemeDefinition, type ThemeCartItem, type ThemeCategory, type ThemeEditorialItem, type ThemeHomeSection, type ThemeNavigationItem, type ThemePageSummary, type ThemeProduct, type ThemeRuntimeAdapters, type ThemeSite } from "@nuvler/theme-sdk";
5
5
  import { nuvlerDefaultTheme } from "./definition.js";
6
+ import { ThemeInteractionProvider } from "./product-detail-interactive.js";
6
7
  import { plainText, ThemeImageView } from "./shared.js";
7
8
 
8
9
  interface PreviewContext {
9
10
  store: { name: string; slug: string };
10
11
  site: { modules: string[]; settings: ThemeSite["settings"] };
11
- navigation: { pages: ThemePageSummary[]; categories: ThemeCategory[] };
12
+ navigation: { pages: ThemePageSummary[]; categories: ThemeCategory[]; menu?: ThemeNavigationItem[] };
12
13
  home: { content: { sections: ThemeHomeSection[] } };
13
14
  catalog: { products: ThemeProduct[] };
14
15
  editorial: { posts: ThemeEditorialItem[]; services: ThemeEditorialItem[]; cases: ThemeEditorialItem[] };
@@ -37,7 +38,7 @@ function catalogHref(route: Extract<PreviewRoute, { type: "catalog" }>, page: nu
37
38
  if (route.search) params.set("busca", route.search);
38
39
  route.variants.forEach((variant) => params.append("variante", variant));
39
40
  if (page > 1) params.set("pagina", String(page));
40
- const pathname = route.categoryPath.length ? `/categoria/${route.categoryPath.map(encodeURIComponent).join("/")}` : "/produtos";
41
+ const pathname = route.categoryPath.length ? `/${route.categoryPath.map(encodeURIComponent).join("/")}` : "/produtos";
41
42
  return params.size ? `${pathname}?${params}` : pathname;
42
43
  }
43
44
 
@@ -94,11 +95,11 @@ export function createNuvlerDefaultRuntime(themeDefinition: NuvlerStoreThemeDefi
94
95
  let content;
95
96
  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} template={themeDefinition.template} /></main>;
96
97
  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>;
97
- 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 ? `/categoria/${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>;
98
+ 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>;
98
99
  else if (route.type === "editorial-list") content = <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"><EditorialPreview items={route.items} basePath={route.basePath} /></div></section></main>;
99
100
  else if (route.type === "editorial-detail") content = <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>;
100
101
  else content = <main className="not-found-page"><div className="not-found-card"><span>{route.type === "loading" ? "Carregando" : "404"}</span><h1>{route.title || (route.type === "loading" ? "Buscando conteúdo da loja" : "Conteúdo não encontrado")}</h1></div></main>;
101
- return <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} template={themeDefinition.template} searchProducts={adapters?.searchProducts} cart={cartButton} /><div className="store-page">{content}</div><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={`/produto/${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>;
102
+ 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} template={themeDefinition.template} searchProducts={adapters?.searchProducts} cart={cartButton} /><div className="store-page">{content}</div><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>;
102
103
  }
103
104
 
104
105
  Theme.displayName = `NuvlerThemeRuntime(${themeDefinition.manifest.id})`;
@@ -516,6 +516,7 @@ select {
516
516
  .mobile-menu-links a { padding: 12px 4px; font-size: 13px; font-weight: 750; }
517
517
  .mobile-menu-categories { padding: 18px 16px; }
518
518
  .mobile-menu-categories h2 { margin: 0 0 10px; color: var(--store-muted); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
519
+ .mobile-menu-category-status { margin: 0 0 10px; color: var(--store-muted); font-size: 12px; }
519
520
  .mobile-menu-categories > a,
520
521
  .mobile-menu-category > summary { display: flex; min-height: 44px; align-items: center; justify-content: space-between; border-bottom: 1px solid color-mix(in srgb, var(--store-line), transparent 35%); padding: 8px 4px; cursor: pointer; font-size: 13px; font-weight: 750; list-style: none; }
521
522
  .mobile-menu-category summary::-webkit-details-marker { display: none; }
@@ -647,6 +648,7 @@ select {
647
648
 
648
649
  .main-nav {
649
650
  display: flex;
651
+ position: relative;
650
652
  min-height: 45px;
651
653
  align-items: center;
652
654
  justify-content: center;
@@ -655,6 +657,53 @@ select {
655
657
  font-weight: 700;
656
658
  }
657
659
 
660
+ .main-nav-group {
661
+ display: flex;
662
+ position: static;
663
+ min-height: 45px;
664
+ align-items: stretch;
665
+ }
666
+
667
+ .main-nav-group > a {
668
+ display: inline-flex;
669
+ position: relative;
670
+ align-items: center;
671
+ gap: 5px;
672
+ }
673
+
674
+ .main-nav-group > a::after {
675
+ position: absolute;
676
+ right: 0;
677
+ bottom: 0;
678
+ left: 0;
679
+ height: 2px;
680
+ transform: scaleX(0);
681
+ background: var(--color-primary);
682
+ content: "";
683
+ transition: transform 160ms ease;
684
+ }
685
+
686
+ .main-nav-group:hover > a::after,
687
+ .main-nav-group:focus-within > a::after {
688
+ transform: scaleX(1);
689
+ }
690
+
691
+ .category-item-chevron {
692
+ width: 13px;
693
+ height: 13px;
694
+ fill: none;
695
+ stroke: currentColor;
696
+ stroke-width: 1.8;
697
+ transition: transform 160ms ease;
698
+ }
699
+
700
+ .main-nav-group:hover .category-item-chevron,
701
+ .main-nav-group:focus-within .category-item-chevron,
702
+ .category-nav-group:hover .category-item-chevron,
703
+ .category-nav-group:focus-within .category-item-chevron {
704
+ transform: rotate(180deg);
705
+ }
706
+
658
707
  .category-nav {
659
708
  position: relative;
660
709
  overflow: visible;
@@ -799,6 +848,13 @@ select {
799
848
  scrollbar-width: thin;
800
849
  }
801
850
 
851
+ .category-nav-status {
852
+ margin: 0;
853
+ padding: 12px 16px 0;
854
+ color: var(--store-muted);
855
+ font-size: 12px;
856
+ }
857
+
802
858
  .category-nav-tree-node > a {
803
859
  display: flex;
804
860
  width: 100%;
@@ -858,10 +914,76 @@ select {
858
914
  }
859
915
 
860
916
  .category-nav-group:hover .category-nav-submenu,
861
- .category-nav-group:focus-within .category-nav-submenu {
917
+ .category-nav-group:focus-within .category-nav-submenu,
918
+ .main-nav-group:hover .configured-category-submenu,
919
+ .main-nav-group:focus-within .configured-category-submenu {
862
920
  display: grid;
863
921
  }
864
922
 
923
+ .configured-category-submenu {
924
+ grid-template-columns: minmax(0, 1fr);
925
+ gap: 0;
926
+ overflow: hidden;
927
+ padding: 0;
928
+ }
929
+
930
+ .configured-category-heading {
931
+ display: flex;
932
+ align-items: center;
933
+ justify-content: space-between;
934
+ gap: 20px;
935
+ border-bottom: 1px solid var(--store-line);
936
+ padding: 18px 20px;
937
+ background: color-mix(in srgb, var(--color-secondary), transparent 93%);
938
+ }
939
+
940
+ .configured-category-heading > div {
941
+ display: grid;
942
+ gap: 3px;
943
+ }
944
+
945
+ .configured-category-heading span {
946
+ color: var(--store-muted);
947
+ font-size: 9px;
948
+ font-weight: 850;
949
+ letter-spacing: .12em;
950
+ text-transform: uppercase;
951
+ }
952
+
953
+ .configured-category-heading strong {
954
+ color: var(--store-text);
955
+ font-size: 17px;
956
+ }
957
+
958
+ .main-nav .configured-category-heading > a {
959
+ border-radius: 999px;
960
+ background: var(--color-secondary);
961
+ padding: 9px 13px;
962
+ color: #fff;
963
+ font-size: 11px;
964
+ }
965
+
966
+ .main-nav .configured-category-heading > a:hover {
967
+ background: color-mix(in srgb, var(--color-secondary), #000 14%);
968
+ color: #fff;
969
+ }
970
+
971
+ .configured-category-grid {
972
+ display: grid;
973
+ max-height: 410px;
974
+ grid-template-columns: repeat(4, minmax(0, 1fr));
975
+ align-content: start;
976
+ gap: 8px 12px;
977
+ overflow-y: auto;
978
+ padding: 14px;
979
+ }
980
+
981
+ .configured-category-grid > .category-nav-tree-node > a {
982
+ background: color-mix(in srgb, var(--color-secondary), transparent 93%);
983
+ font-size: 13px;
984
+ font-weight: 800;
985
+ }
986
+
865
987
  .category-nav-submenu a {
866
988
  display: flex;
867
989
  width: 100%;
@@ -932,6 +1054,7 @@ select {
932
1054
 
933
1055
  .category-nav-inner > .category-nav-group > a {
934
1056
  position: relative;
1057
+ gap: 5px;
935
1058
  color: var(--color-secondary);
936
1059
  }
937
1060
 
@@ -1665,7 +1788,7 @@ select {
1665
1788
  align-items: stretch;
1666
1789
  overflow-x: auto;
1667
1790
  gap: 22px;
1668
- padding: 5px 2px 25px;
1791
+ padding: 5px 0 25px;
1669
1792
  scroll-behavior: smooth;
1670
1793
  scroll-snap-type: x mandatory;
1671
1794
  scrollbar-width: none;
@@ -1689,6 +1812,7 @@ select {
1689
1812
  .product-carousel .carousel-arrow-next { right: -21px; }
1690
1813
 
1691
1814
  .product-card {
1815
+ position: relative;
1692
1816
  display: flex;
1693
1817
  width: 100%;
1694
1818
  height: 100%;
@@ -1785,9 +1909,21 @@ select {
1785
1909
  }
1786
1910
 
1787
1911
  .product-card-content > .button {
1912
+ position: relative;
1913
+ z-index: 1;
1788
1914
  margin-top: auto;
1789
1915
  }
1790
1916
 
1917
+ .product-card-details-link::after {
1918
+ position: absolute;
1919
+ inset: 0;
1920
+ content: "";
1921
+ }
1922
+
1923
+ .product-card-action {
1924
+ cursor: pointer;
1925
+ }
1926
+
1791
1927
  .benefits-section {
1792
1928
  border-top: 1px solid var(--store-line);
1793
1929
  border-bottom: 1px solid var(--store-line);
@@ -4,7 +4,7 @@
4
4
  "name": "__NUVLER_THEME_NAME__",
5
5
  "version": "0.1.0",
6
6
  "runtimeVersion": "1",
7
- "sdkVersion": "^1.2.0",
7
+ "sdkVersion": "^1.2.2",
8
8
  "entry": "src/theme.tsx",
9
9
  "styles": ["src/theme.css"],
10
10
  "presentation": {
@@ -9,16 +9,17 @@
9
9
  "build": "nuvler theme build --theme .",
10
10
  "pack": "nuvler theme pack --theme .",
11
11
  "publish": "nuvler theme publish --theme .",
12
+ "upgrade": "nuvler theme upgrade --theme .",
12
13
  "typecheck": "tsc -p tsconfig.json --noEmit"
13
14
  },
14
15
  "dependencies": {
15
- "@nuvler/theme-sdk": "^1.2.0"
16
+ "@nuvler/theme-sdk": "^1.2.2"
16
17
  },
17
18
  "peerDependencies": {
18
19
  "react": "^19.0.0"
19
20
  },
20
21
  "devDependencies": {
21
- "@nuvler/cli": "^0.4.2",
22
+ "@nuvler/cli": "^0.4.4",
22
23
  "@types/react": "^19.0.0",
23
24
  "react": "^19.0.0",
24
25
  "typescript": "^5.9.0"
@@ -1,6 +1,7 @@
1
1
  import manifestData from "../nuvler.theme.json" with { type: "json" };
2
2
  import {
3
3
  defineTheme,
4
+ productUrl,
4
5
  type FooterProps,
5
6
  type HeaderProps,
6
7
  type HomeProps,
@@ -20,7 +21,7 @@ function Footer({ site }: FooterProps) {
20
21
  }
21
22
 
22
23
  function ProductGrid({ products }: ProductGridProps) {
23
- return <div className="theme-products">{products.map((product) => <article key={product.slug}><a href={`/produto/${product.slug}`}><strong>{product.title}</strong><span>{product.sku || "Ver produto"}</span></a></article>)}</div>;
24
+ return <div className="theme-products">{products.map((product) => <article key={product.slug}><a href={productUrl(product)}><strong>{product.title}</strong><span>{product.sku || "Ver produto"}</span></a></article>)}</div>;
24
25
  }
25
26
 
26
27
  function Home({ products, site }: HomeProps) {
@@ -29,7 +30,7 @@ function Home({ products, site }: HomeProps) {
29
30
  }
30
31
 
31
32
  function ProductDetail({ product, descriptionContent, onAddToCart }: ProductDetailProps) {
32
- return <article className="theme-product-detail"><div><span>{product.categories[0]?.name || "Produto"}</span><h1>{product.title}</h1>{descriptionContent}</div><button type="button" onClick={() => onAddToCart?.({ productSlug: product.slug, title: product.title, sku: product.sku, image: product.image, unitPrice: product.promotionalPrice ?? product.price })}>Adicionar ao orçamento</button></article>;
33
+ return <article className="theme-product-detail"><div><span>{product.categories[0]?.name || "Produto"}</span><h1>{product.title}</h1>{descriptionContent}</div><button type="button" onClick={() => onAddToCart?.({ productSlug: product.slug, productUrl: productUrl(product), title: product.title, sku: product.sku, image: product.image, unitPrice: product.promotionalPrice ?? product.price })}>Adicionar ao orçamento</button></article>;
33
34
  }
34
35
 
35
36
  export const manifest = manifestData as ThemeManifest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuvler/cli",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "CLI oficial para criação, validação, preview e empacotamento de temas Nuvler",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@nuvler/theme-schema": "^1.2.0",
24
- "@nuvler/theme-sdk": "^1.2.0",
24
+ "@nuvler/theme-sdk": "^1.2.2",
25
25
  "@vitejs/plugin-react": "^6.0.5",
26
26
  "commander": "^15.0.0",
27
27
  "react": "19.2.8",
@@ -10,7 +10,7 @@
10
10
  "typecheck": "tsc -p tsconfig.json --noEmit"
11
11
  },
12
12
  "dependencies": {
13
- "@nuvler/theme-sdk": "1.2.0",
13
+ "@nuvler/theme-sdk": "1.2.2",
14
14
  "react": "19.2.8",
15
15
  "react-dom": "19.2.8"
16
16
  },
@@ -8,6 +8,7 @@ import type {
8
8
  ThemeProduct,
9
9
  ThemeSiteColors,
10
10
  } from "@nuvler/theme-sdk";
11
+ import { htmlToPlainText, productUrl } from "@nuvler/theme-sdk";
11
12
  import type { DefaultThemeProps, ThemeRuntimeAdapters } from "./index.js";
12
13
  import type { ThemeRoute } from "./index.js";
13
14
 
@@ -57,11 +58,7 @@ function dataLimit(data: Record<string, unknown>): number {
57
58
  }
58
59
 
59
60
  function plainText(value: string): string {
60
- return value
61
- .replace(/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi, " ")
62
- .replace(/<[^>]+>/g, " ")
63
- .replace(/\s+/g, " ")
64
- .trim();
61
+ return htmlToPlainText(value);
65
62
  }
66
63
 
67
64
  function moduleLinks(context: ThemeContext): Array<{ label: string; href: string }> {
@@ -77,7 +74,7 @@ function moduleLinks(context: ThemeContext): Array<{ label: string; href: string
77
74
  }
78
75
 
79
76
  function categoryUrl(path: string[]): string {
80
- return `/categoria/${path.map(encodeURIComponent).join("/")}`;
77
+ return `/${path.map(encodeURIComponent).join("/")}`;
81
78
  }
82
79
 
83
80
  function CategoryTree({
@@ -156,7 +153,7 @@ function SmartSearch({ adapters }: { adapters: ThemeRuntimeAdapters }) {
156
153
  </form>
157
154
  {open && value.trim().length >= 2 && <div className="search-suggestions">
158
155
  <div className="search-suggestions-heading"><strong>{loading ? "Buscando..." : "Produtos encontrados"}</strong>{!loading && <span>{results.length} de 5</span>}</div>
159
- {!loading && results.map((product) => <Link href={`/produto/${product.slug}`} key={product.slug}>
156
+ {!loading && results.map((product) => <Link href={productUrl(product)} key={product.slug}>
160
157
  <span className="search-suggestion-image"><Image image={product.image} fallbackAlt={product.title} /></span>
161
158
  <span className="search-suggestion-copy"><strong>{product.title}</strong><small>{product.sku ? `Ref. ${product.sku}` : product.categories[0]?.name || "Produto"}</small></span>
162
159
  {displayPrice(product) && <b>{displayPrice(product)}</b>}
@@ -265,9 +262,10 @@ function ProductCard({ product, context, adapters }: {
265
262
  }) {
266
263
  const { Link, Image } = adapters;
267
264
  const catalog = context.site.settings?.catalog ?? fallbackCatalog;
265
+ const href = productUrl(product);
268
266
  return (
269
267
  <article className="product-card">
270
- <Link className="product-card-image" href={`/produto/${product.slug}`}>
268
+ <Link className="product-card-image" href={href}>
271
269
  <Image image={product.image} fallbackAlt={product.title} />
272
270
  </Link>
273
271
  <div className="product-card-content">
@@ -276,11 +274,11 @@ function ProductCard({ product, context, adapters }: {
276
274
  {product.categories[0]?.name || "Sem categoria"}
277
275
  </span>
278
276
  )}
279
- <h3><Link href={`/produto/${product.slug}`}>{product.title}</Link></h3>
277
+ <h3><Link href={href}>{product.title}</Link></h3>
280
278
  {catalog.showDescription && product.description && (
281
279
  <p className="product-card-description">{plainText(product.description)}</p>
282
280
  )}
283
- <Link className="button button-secondary button-block" href={`/produto/${product.slug}`}>
281
+ <Link className="button button-secondary button-block" href={href}>
284
282
  Ver detalhes e orçar
285
283
  </Link>
286
284
  </div>
@@ -374,11 +372,14 @@ function TextSection({ section, adapters }: ThemeSectionRendererProps) {
374
372
  function ProductsSection({ section, context, adapters }: ThemeSectionRendererProps) {
375
373
  const categorySlug = dataString(section.data, "categorySlug");
376
374
  const products = context.catalog.products
377
- .filter((product) => !categorySlug || product.categories.some((category) => category.slug === categorySlug))
375
+ .filter((product) => !categorySlug || product.categories.some((category) => category.slug === categorySlug) || product.categoryPath?.includes(categorySlug))
378
376
  .slice(0, dataLimit(section.data));
379
377
  return <section className="store-section"><div className="store-container">
380
378
  <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>
381
- {products.length ? <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> : <div className="empty-state"><span>7</span><h2>Nenhum produto encontrado</h2><p>Escolha outra categoria ou publique produtos para esta vitrine.</p></div>}
379
+ {products.length ? section.type === "products-grid"
380
+ ? <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>
381
+ : <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>
382
+ : <div className="empty-state"><span>7</span><h2>Nenhum produto encontrado</h2><p>Escolha outra categoria ou publique produtos para esta vitrine.</p></div>}
382
383
  </div></section>;
383
384
  }
384
385