@nuvler/cli 0.4.5 → 0.5.1

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 (44) hide show
  1. package/README.md +10 -5
  2. package/dist/commands/theme/create.js +2 -2
  3. package/dist/commands/theme/dev.js +3 -1
  4. package/dist/commands/theme/dev.js.map +1 -1
  5. package/dist/commands/theme/migrate.js +7 -0
  6. package/dist/commands/theme/migrate.js.map +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/migrate/analysis/dependency-classifier.js +41 -0
  9. package/dist/migrate/analysis/dependency-classifier.js.map +1 -0
  10. package/dist/migrate/analysis/dependency-graph.js +210 -0
  11. package/dist/migrate/analysis/dependency-graph.js.map +1 -0
  12. package/dist/migrate/analyzer.js +102 -3
  13. package/dist/migrate/analyzer.js.map +1 -1
  14. package/dist/migrate/asset-copier.js +2 -2
  15. package/dist/migrate/asset-copier.js.map +1 -1
  16. package/dist/migrate/generation/fidelity-pass.js +233 -0
  17. package/dist/migrate/generation/fidelity-pass.js.map +1 -0
  18. package/dist/migrate/generator.js +1488 -64
  19. package/dist/migrate/generator.js.map +1 -1
  20. package/dist/migrate/resolvers/import-resolver.js +91 -0
  21. package/dist/migrate/resolvers/import-resolver.js.map +1 -0
  22. package/dist/migrate/transform/source-transformer.js +452 -0
  23. package/dist/migrate/transform/source-transformer.js.map +1 -0
  24. package/dist/migrate/transformer.js +326 -1
  25. package/dist/migrate/transformer.js.map +1 -1
  26. package/dist/nuvler.js +3601 -314
  27. package/dist/nuvler.js.map +1 -1
  28. package/dist/preview/prepare.js +8 -1
  29. package/dist/preview/prepare.js.map +1 -1
  30. package/dist/templates/nuvler-atelier/nuvler.theme.json +24 -10
  31. package/dist/templates/nuvler-atelier/package.json +3 -3
  32. package/dist/templates/nuvler-default/nuvler.theme.json +24 -10
  33. package/dist/templates/nuvler-default/package.json +9 -4
  34. package/dist/templates/nuvler-default/src/home.tsx +74 -2
  35. package/dist/templates/nuvler-default/src/theme-component.tsx +4 -3
  36. package/dist/templates/nuvler-default/src/theme.css +149 -0
  37. package/dist/templates/starter/nuvler.theme.json +1 -1
  38. package/dist/templates/starter/package.json +2 -2
  39. package/package.json +4 -4
  40. package/preview-host/package.json +1 -1
  41. package/preview-host/src/app/globals.css +5 -15
  42. package/preview-host/src/main.tsx +55 -5
  43. package/preview-host/vendor/theme-runtime/default-theme.tsx +131 -3
  44. package/preview-host/vite.config.ts +14 -0
@@ -1,3 +1,4 @@
1
+ import { ThemeContextSchema } from "@nuvler/theme-schema";
1
2
  import { loadThemeContext } from "../api/theme-context.js";
2
3
  import { loadDeveloperSession, requireAuthorizedTenant, } from "../config/developer-session.js";
3
4
  import { readThemeProjectConfig } from "../config/project.js";
@@ -14,6 +15,12 @@ export async function prepareThemePreview(options) {
14
15
  if (context.store.slug !== tenant.slug) {
15
16
  throw new Error(`A API retornou contexto do tenant "${context.store.slug}" para "${tenant.slug}".`);
16
17
  }
17
- return { project, context, apiUrl: session.apiUrl, tenant };
18
+ return {
19
+ project,
20
+ context: ThemeContextSchema.parse(context),
21
+ apiUrl: session.apiUrl,
22
+ tenant,
23
+ migrationSeedSections: 0,
24
+ };
18
25
  }
19
26
  //# sourceMappingURL=prepare.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../src/preview/prepare.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAqB,MAAM,qBAAqB,CAAC;AAa1E,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAIzC;IACC,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAC/D,MAAM,UAAU,GAA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"0.1.3",
6
6
  "runtimeVersion": "1",
7
- "sdkVersion": "^1.2.2",
7
+ "sdkVersion": "^1.3.1",
8
8
  "entry": "src/theme.tsx",
9
- "styles": ["src/theme.css"],
9
+ "styles": [
10
+ "src/theme.css"
11
+ ],
10
12
  "presentation": {
11
13
  "description": "Tema editorial com composição assimétrica, imagens protagonistas e navegação refinada.",
12
14
  "templateId": "nuvler-atelier",
13
15
  "colors": {
14
- "primary": "#153f3a", "primaryText": "#ffffff",
15
- "secondary": "#ff6b3d", "secondaryText": "#17201e", "accent": "#ff6b3d",
16
- "background": "#f3efe5", "surface": "#fffaf0", "surfaceAlt": "#e8e1d3",
17
- "text": "#17201e", "textMuted": "#6b716e", "border": "#d5cdbd",
18
- "headerBackground": "#f3efe5", "headerText": "#17201e",
19
- "footerBackground": "#101c1a", "footerText": "#ffffff"
16
+ "primary": "#153f3a",
17
+ "secondary": "#ff6b3d",
18
+ "background": "#f3efe5",
19
+ "text": "#17201e",
20
+ "primaryText": "#ffffff",
21
+ "secondaryText": "#17201e",
22
+ "accent": "#ff6b3d",
23
+ "surface": "#fffaf0",
24
+ "surfaceAlt": "#e8e1d3",
25
+ "textMuted": "#6b716e",
26
+ "border": "#d5cdbd",
27
+ "headerBackground": "#f3efe5",
28
+ "headerText": "#17201e",
29
+ "footerBackground": "#101c1a",
30
+ "footerText": "#ffffff"
20
31
  },
21
- "layout": { "containerWidth": 1380, "borderRadius": 8 }
32
+ "layout": {
33
+ "containerWidth": 1380,
34
+ "borderRadius": 8
35
+ }
22
36
  }
23
37
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuvler-theme-nuvler-atelier",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -13,13 +13,13 @@
13
13
  "typecheck": "tsc -p tsconfig.json --noEmit"
14
14
  },
15
15
  "dependencies": {
16
- "@nuvler/theme-sdk": "^1.2.2"
16
+ "@nuvler/theme-sdk": "^1.3.1"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "react": "^19.0.0"
20
20
  },
21
21
  "devDependencies": {
22
- "@nuvler/cli": "^0.4.5",
22
+ "@nuvler/cli": "^0.5.1",
23
23
  "@types/react": "^19.0.0",
24
24
  "react": "^19.0.0",
25
25
  "typescript": "^5.9.0"
@@ -2,22 +2,36 @@
2
2
  "schemaVersion": 1,
3
3
  "id": "nuvler-default",
4
4
  "name": "Nuvler Default",
5
- "version": "1.0.4",
5
+ "version": "1.0.5",
6
6
  "runtimeVersion": "1",
7
- "sdkVersion": "^1.2.2",
7
+ "sdkVersion": "^1.3.1",
8
8
  "entry": "src/theme.tsx",
9
- "styles": ["src/theme.css"],
9
+ "styles": [
10
+ "src/theme.css"
11
+ ],
10
12
  "presentation": {
11
13
  "description": "Tema oficial completo, indicado para produção e usado como base confiável.",
12
14
  "templateId": "nuvler-default",
13
15
  "colors": {
14
- "primary": "#176b3a", "primaryText": "#ffffff",
15
- "secondary": "#d99b31", "secondaryText": "#18221b", "accent": "#b45309",
16
- "background": "#f7f7f2", "surface": "#ffffff", "surfaceAlt": "#eef2e9",
17
- "text": "#18221b", "textMuted": "#657068", "border": "#dfe4dd",
18
- "headerBackground": "#ffffff", "headerText": "#18221b",
19
- "footerBackground": "#14251a", "footerText": "#f7f7f2"
16
+ "primary": "#176b3a",
17
+ "secondary": "#d99b31",
18
+ "background": "#f7f7f2",
19
+ "text": "#18221b",
20
+ "primaryText": "#ffffff",
21
+ "secondaryText": "#18221b",
22
+ "accent": "#b45309",
23
+ "surface": "#ffffff",
24
+ "surfaceAlt": "#eef2e9",
25
+ "textMuted": "#657068",
26
+ "border": "#dfe4dd",
27
+ "headerBackground": "#ffffff",
28
+ "headerText": "#18221b",
29
+ "footerBackground": "#14251a",
30
+ "footerText": "#f7f7f2"
20
31
  },
21
- "layout": { "containerWidth": 1280, "borderRadius": 18 }
32
+ "layout": {
33
+ "containerWidth": 1280,
34
+ "borderRadius": 18
35
+ }
22
36
  }
23
37
  }
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@nuvler/theme-default",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Tema padrão oficial da Nuvler",
5
5
  "type": "module",
6
- "sideEffects": ["**/*.css"],
6
+ "sideEffects": [
7
+ "**/*.css"
8
+ ],
7
9
  "main": "./dist/src/index.js",
8
10
  "types": "./dist/src/index.d.ts",
9
11
  "exports": {
@@ -45,7 +47,10 @@
45
47
  "./styles.css": "./dist/theme.css",
46
48
  "./manifest": "./dist/nuvler.theme.json"
47
49
  },
48
- "files": ["dist", "README.md"],
50
+ "files": [
51
+ "dist",
52
+ "README.md"
53
+ ],
49
54
  "scripts": {
50
55
  "dev": "nuvler theme dev --theme .",
51
56
  "validate": "nuvler theme validate --theme .",
@@ -59,7 +64,7 @@
59
64
  "react": "^19.0.0"
60
65
  },
61
66
  "dependencies": {
62
- "@nuvler/theme-sdk": "^1.2.2"
67
+ "@nuvler/theme-sdk": "^1.3.1"
63
68
  },
64
69
  "devDependencies": {
65
70
  "@types/react": "^19.0.0",
@@ -1,4 +1,5 @@
1
- import type { HomeProps, ThemeEditorialItem, ThemeHomeSection, ThemeImage, ThemeSite } from "@nuvler/theme-sdk";
1
+ import { useState, type FormEvent } from "react";
2
+ import type { HomeProps, ThemeContactSubmissionInput, ThemeEditorialItem, ThemeHomeSection, ThemeImage, ThemeSite } from "@nuvler/theme-sdk";
2
3
  import { BannerCarousel, type ThemeBanner } from "./banner-carousel.js";
3
4
  import { ProductCarousel } from "./product-carousel.js";
4
5
  import { ProductGrid } from "./products.js";
@@ -14,6 +15,18 @@ function limit(data: Record<string, unknown>) {
14
15
  return Number.isInteger(value) ? Math.min(12, Math.max(1, value)) : 6;
15
16
  }
16
17
 
18
+ function record(data: Record<string, unknown>, key: string): Record<string, unknown> {
19
+ const value = data[key];
20
+ return value && typeof value === "object" && !Array.isArray(value) ? value as Record<string, unknown> : {};
21
+ }
22
+
23
+ function records(data: Record<string, unknown>, key: string): Record<string, unknown>[] {
24
+ const value = data[key];
25
+ return Array.isArray(value)
26
+ ? value.filter((item): item is Record<string, unknown> => Boolean(item) && typeof item === "object" && !Array.isArray(item))
27
+ : [];
28
+ }
29
+
17
30
  function productCategory(data: Record<string, unknown>) {
18
31
  const value = text(data, "categorySlug").toLocaleLowerCase("pt-BR");
19
32
  if (["", "all", "todos", "todas", "all-categories", "todas-as-categorias"].includes(value)) return "";
@@ -81,13 +94,72 @@ function TextSection({ section, ImageComponent = ThemeImageView }: { section: Th
81
94
  return <section className="store-section editorial-section"><div className="store-container editorial-content">{text(section.data, "eyebrow") && <span>{text(section.data, "eyebrow")}</span>}<h2>{title}</h2>{description && <p>{description}</p>}{section.type === "cta" && text(section.data, "buttonLabel") && text(section.data, "buttonUrl") && <a className="button button-primary" href={text(section.data, "buttonUrl")}>{text(section.data, "buttonLabel")}</a>}</div></section>;
82
95
  }
83
96
 
84
- export function Home({ sections, products, posts, services, cases, site, template, ImageComponent = ThemeImageView }: HomeProps & { ImageComponent?: ThemeImageComponent }) {
97
+ function ContactForm({ section, submitContact }: { section: ThemeHomeSection; submitContact?: (submission: ThemeContactSubmissionInput) => Promise<unknown> }) {
98
+ const props = record(section.data, "props");
99
+ const configured = records(props, "fields");
100
+ const fields = configured;
101
+ const [status, setStatus] = useState<"idle" | "sending" | "success" | "error">("idle");
102
+ const [error, setError] = useState("");
103
+ const submit = async (event: FormEvent<HTMLFormElement>) => {
104
+ event.preventDefault();
105
+ if (!submitContact) {
106
+ setStatus("error");
107
+ setError("O envio de contatos ainda não está disponível.");
108
+ return;
109
+ }
110
+ const formElement = event.currentTarget;
111
+ const form = new FormData(formElement);
112
+ const values: ThemeContactSubmissionInput["values"] = {};
113
+ fields.forEach((field) => {
114
+ const key = text(field, "key");
115
+ if (!key) return;
116
+ if (text(field, "type") === "checkbox") {
117
+ values[key] = form.has(key);
118
+ return;
119
+ }
120
+ const entries = form.getAll(key).map(String);
121
+ values[key] = entries.length > 1 ? entries : entries[0] ?? "";
122
+ });
123
+ setStatus("sending");
124
+ setError("");
125
+ try {
126
+ await submitContact({ formKey: text(section.data, "componentKey", "contact-form"), sectionId: section.id, values, pathname: typeof window === "undefined" ? undefined : window.location.pathname });
127
+ formElement.reset();
128
+ setStatus("success");
129
+ } catch (cause) {
130
+ setStatus("error");
131
+ setError(cause instanceof Error ? cause.message : "Não foi possível enviar o contato.");
132
+ }
133
+ };
134
+ return <section className="store-section theme-component-section contact-form-section"><div className="store-container contact-form-layout"><div className="contact-form-copy">{text(props, "eyebrow") && <span>{text(props, "eyebrow")}</span>}{text(props, "title") && <h2>{text(props, "title")}</h2>}{text(props, "description") && <p>{text(props, "description")}</p>}</div><form className="contact-form" onSubmit={(event) => void submit(event)}>{fields.map((field) => {
135
+ const key = text(field, "key");
136
+ const type = text(field, "type", "text");
137
+ const label = text(field, "label", key);
138
+ const required = field.required === true;
139
+ if (!key) return null;
140
+ if (type === "checkbox") return <label className="contact-form-wide contact-form-checkbox" key={key}><input name={key} required={required} type="checkbox" value="true" /><span>{label}{required && <small aria-hidden="true"> *</small>}</span></label>;
141
+ if (type === "select") return <label key={key}><span>{label}{required && <small aria-hidden="true"> *</small>}</span><select name={key} required={required}>{records(field, "options").map((option) => <option key={text(option, "value")} value={text(option, "value")}>{text(option, "label", text(option, "value"))}</option>)}</select></label>;
142
+ return <label className={type === "textarea" ? "contact-form-wide" : ""} key={key}><span>{label}{required && <small aria-hidden="true"> *</small>}</span>{type === "textarea" ? <textarea name={key} placeholder={text(field, "placeholder")} required={required} rows={5} /> : <input name={key} placeholder={text(field, "placeholder")} required={required} type={["email", "tel", "url", "number"].includes(type) ? type : "text"} />}</label>;
143
+ })}<div className="contact-form-wide"><button className="button button-primary" disabled={status === "sending"} type="submit">{status === "sending" ? "" : text(props, "submitLabel")}</button>{status === "success" && text(props, "successMessage") && <p className="contact-form-feedback" role="status">{text(props, "successMessage")}</p>}{status === "error" && <p className="contact-form-feedback contact-form-error" role="alert">{error}</p>}</div></form></div></section>;
144
+ }
145
+
146
+ function ThemeComponent({ section, submitContact }: { section: ThemeHomeSection; submitContact?: HomeProps["submitContact"] }) {
147
+ const componentKey = text(section.data, "componentKey");
148
+ const props = record(section.data, "props");
149
+ if (componentKey === "contact-form" || componentKey.endsWith("-form")) return <ContactForm section={section} submitContact={submitContact} />;
150
+ if (componentKey === "video") return <section className="store-section theme-component-section" data-component-key="video"><div className="store-container">{text(props, "eyebrow") && <span>{text(props, "eyebrow")}</span>}{text(props, "title") && <h2>{text(props, "title")}</h2>}{text(props, "description") && <p>{text(props, "description")}</p>}{text(props, "videoUrl") && <video className="theme-component-video" controls playsInline poster={text(props, "posterImageUrl") || undefined} src={text(props, "videoUrl")} />}</div></section>;
151
+ const items = records(props, "items");
152
+ return <section className="store-section theme-component-section" data-component-key={componentKey || undefined}><div className="store-container">{text(props, "eyebrow") && <span>{text(props, "eyebrow")}</span>}{text(props, "title") && <h2>{text(props, "title")}</h2>}{text(props, "description") && <p>{text(props, "description")}</p>}{items.length > 0 && <div className="theme-component-items">{items.map((item, index) => { const itemTitle = text(item, "value", text(item, "title", text(item, "question"))); return <article key={index}>{itemTitle && <strong>{itemTitle}</strong>}{text(item, "description", text(item, "answer")) && <p>{text(item, "description", text(item, "answer"))}</p>}</article>; })}</div>}</div></section>;
153
+ }
154
+
155
+ export function Home({ sections, products, posts, services, cases, site, template, submitContact, ImageComponent = ThemeImageView }: HomeProps & { ImageComponent?: ThemeImageComponent }) {
85
156
  const visible = [...sections].filter((section) => section.enabled).sort((a, b) => a.order - b.order);
86
157
  const rendered = visible.length ? visible : template.fallbackSections(site.modules);
87
158
  const catalog = site.settings?.catalog ?? { showCategory: true, showDescription: true, desktopColumns: 4 as const };
88
159
  return <>{rendered.map((section, index) => {
89
160
  if (section.type === "hero") return <Hero key={section.id || index} section={section} site={site} action={template.primaryAction(site.modules)} priority={index === 0} ImageComponent={ImageComponent} />;
90
161
  if (section.type === "banner-carousel") return <BannerCarousel key={section.id || index} banners={banners(section.data)} autoplay={section.data.autoplay !== false} priority={index === 0} ImageComponent={ImageComponent} />;
162
+ if (section.type === "theme-component") return <ThemeComponent key={section.id || index} section={section} submitContact={submitContact} />;
91
163
  if (["image-text", "rich-text", "cta"].includes(section.type)) return <TextSection key={section.id || index} section={section} ImageComponent={ImageComponent} />;
92
164
  if (section.type === "products-grid" || section.type === "products-carousel") {
93
165
  const category = productCategory(section.data);
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import { useMemo, useState, type CSSProperties } from "react";
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";
4
+ import { productUrl, type NuvlerStoreThemeDefinition, type ThemeCartItem, type ThemeCategory, type ThemeEditorialItem, type ThemeHomeSection, type ThemeNavigationItem, type ThemePageSummary, type ThemeProduct, type ThemeRuntimeAdapters, type ThemeRuntimeSdk, type ThemeSite } from "@nuvler/theme-sdk";
5
5
  import { nuvlerDefaultTheme } from "./definition.js";
6
6
  import { ThemeInteractionProvider } from "./product-detail-interactive.js";
7
7
  import { plainText, ThemeImageView } from "./shared.js";
@@ -26,6 +26,7 @@ export interface NuvlerDefaultThemeProps {
26
26
  context: PreviewContext;
27
27
  route?: PreviewRoute;
28
28
  adapters?: ThemeRuntimeAdapters;
29
+ sdk?: ThemeRuntimeSdk;
29
30
  }
30
31
 
31
32
  interface PreviewCartItem extends ThemeCartItem {
@@ -47,7 +48,7 @@ function EditorialPreview({ items, basePath }: { items: ThemeEditorialItem[]; ba
47
48
  }
48
49
 
49
50
  export function createNuvlerDefaultRuntime(themeDefinition: NuvlerStoreThemeDefinition) {
50
- function Theme({ context, route = { type: "home" }, adapters }: NuvlerDefaultThemeProps) {
51
+ function Theme({ context, route = { type: "home" }, adapters, sdk }: NuvlerDefaultThemeProps) {
51
52
  const [cartItems, setCartItems] = useState<PreviewCartItem[]>([]);
52
53
  const [cartOpen, setCartOpen] = useState(false);
53
54
  const { Header, Footer, Home, ProductDetail, ProductGrid } = themeDefinition.components;
@@ -93,7 +94,7 @@ export function createNuvlerDefaultRuntime(themeDefinition: NuvlerStoreThemeDefi
93
94
  };
94
95
  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>;
95
96
  let content;
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>;
97
+ 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>;
97
98
  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>;
98
99
  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>;
99
100
  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>;
@@ -1525,6 +1525,137 @@ select {
1525
1525
  margin-top: 28px;
1526
1526
  }
1527
1527
 
1528
+ .theme-component-section {
1529
+ border-top: 1px solid var(--store-line);
1530
+ background: var(--store-surface);
1531
+ }
1532
+
1533
+ .theme-component-section > .store-container > span,
1534
+ .contact-form-copy > span {
1535
+ display: block;
1536
+ margin-bottom: 10px;
1537
+ color: var(--color-primary);
1538
+ font-size: 11px;
1539
+ font-weight: 900;
1540
+ letter-spacing: .14em;
1541
+ text-transform: uppercase;
1542
+ }
1543
+
1544
+ .theme-component-section h2 {
1545
+ margin: 0;
1546
+ font-size: clamp(30px, 4vw, 48px);
1547
+ letter-spacing: -.04em;
1548
+ }
1549
+
1550
+ .theme-component-section p {
1551
+ color: var(--store-muted);
1552
+ line-height: 1.7;
1553
+ }
1554
+
1555
+ .theme-component-items {
1556
+ display: grid;
1557
+ grid-template-columns: repeat(3, minmax(0, 1fr));
1558
+ gap: 18px;
1559
+ margin-top: 32px;
1560
+ }
1561
+
1562
+ .theme-component-items article {
1563
+ border: 1px solid var(--store-line);
1564
+ border-radius: var(--border-radius);
1565
+ background: var(--store-background);
1566
+ padding: 24px;
1567
+ }
1568
+
1569
+ .theme-component-video {
1570
+ display: block;
1571
+ width: 100%;
1572
+ max-height: 720px;
1573
+ margin-top: 32px;
1574
+ border-radius: var(--border-radius);
1575
+ background: #000;
1576
+ }
1577
+
1578
+ .contact-form-layout {
1579
+ display: grid;
1580
+ grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
1581
+ align-items: start;
1582
+ gap: 64px;
1583
+ }
1584
+
1585
+ .contact-form-copy p {
1586
+ max-width: 520px;
1587
+ margin-top: 18px;
1588
+ }
1589
+
1590
+ .contact-form {
1591
+ display: grid;
1592
+ grid-template-columns: repeat(2, minmax(0, 1fr));
1593
+ gap: 18px;
1594
+ border: 1px solid var(--store-line);
1595
+ border-radius: var(--border-radius);
1596
+ background: var(--store-background);
1597
+ padding: 28px;
1598
+ }
1599
+
1600
+ .contact-form label {
1601
+ display: grid;
1602
+ gap: 8px;
1603
+ color: var(--store-text);
1604
+ font-size: 13px;
1605
+ font-weight: 750;
1606
+ }
1607
+
1608
+ .contact-form input,
1609
+ .contact-form textarea,
1610
+ .contact-form select {
1611
+ width: 100%;
1612
+ border: 1px solid var(--store-line);
1613
+ border-radius: calc(var(--border-radius) * .65);
1614
+ background: var(--store-surface);
1615
+ padding: 12px 14px;
1616
+ color: var(--store-text);
1617
+ font: inherit;
1618
+ }
1619
+
1620
+ .contact-form input:focus,
1621
+ .contact-form textarea:focus,
1622
+ .contact-form select:focus {
1623
+ border-color: var(--color-primary);
1624
+ outline: 3px solid color-mix(in srgb, var(--color-primary), transparent 84%);
1625
+ }
1626
+
1627
+ .contact-form-wide {
1628
+ grid-column: 1 / -1;
1629
+ }
1630
+
1631
+ .contact-form .contact-form-checkbox {
1632
+ display: flex;
1633
+ flex-direction: row;
1634
+ align-items: flex-start;
1635
+ gap: 10px;
1636
+ font-weight: 500;
1637
+ line-height: 1.55;
1638
+ }
1639
+
1640
+ .contact-form .contact-form-checkbox input {
1641
+ width: 18px;
1642
+ height: 18px;
1643
+ margin-top: 2px;
1644
+ padding: 0;
1645
+ accent-color: var(--color-primary);
1646
+ }
1647
+
1648
+ .contact-form-feedback {
1649
+ margin: 12px 0 0;
1650
+ color: var(--color-primary);
1651
+ font-size: 13px;
1652
+ font-weight: 700;
1653
+ }
1654
+
1655
+ .contact-form-error {
1656
+ color: #b42318;
1657
+ }
1658
+
1528
1659
  .image-text-section {
1529
1660
  background: var(--store-surface);
1530
1661
  }
@@ -2908,6 +3039,24 @@ select {
2908
3039
  padding: 62px 0;
2909
3040
  }
2910
3041
 
3042
+ .contact-form-layout,
3043
+ .theme-component-items {
3044
+ grid-template-columns: 1fr;
3045
+ }
3046
+
3047
+ .contact-form-layout {
3048
+ gap: 32px;
3049
+ }
3050
+
3051
+ .contact-form {
3052
+ grid-template-columns: 1fr;
3053
+ padding: 20px;
3054
+ }
3055
+
3056
+ .contact-form-wide {
3057
+ grid-column: auto;
3058
+ }
3059
+
2911
3060
  .section-heading {
2912
3061
  align-items: flex-start;
2913
3062
  flex-direction: column;
@@ -4,7 +4,7 @@
4
4
  "name": "__NUVLER_THEME_NAME__",
5
5
  "version": "0.1.0",
6
6
  "runtimeVersion": "1",
7
- "sdkVersion": "^1.2.2",
7
+ "sdkVersion": "^1.3.1",
8
8
  "entry": "src/theme.tsx",
9
9
  "styles": ["src/theme.css"],
10
10
  "presentation": {
@@ -13,13 +13,13 @@
13
13
  "typecheck": "tsc -p tsconfig.json --noEmit"
14
14
  },
15
15
  "dependencies": {
16
- "@nuvler/theme-sdk": "^1.2.2"
16
+ "@nuvler/theme-sdk": "^1.3.1"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "react": "^19.0.0"
20
20
  },
21
21
  "devDependencies": {
22
- "@nuvler/cli": "^0.4.5",
22
+ "@nuvler/cli": "^0.5.1",
23
23
  "@types/react": "^19.0.0",
24
24
  "react": "^19.0.0",
25
25
  "typescript": "^5.9.0"
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@nuvler/cli",
3
- "version": "0.4.5",
3
+ "version": "0.5.1",
4
4
  "description": "CLI oficial para criação, validação, preview e empacotamento de temas Nuvler",
5
5
  "type": "module",
6
6
  "bin": {
7
- "nuvler": "./dist/nuvler.js"
7
+ "nuvler": "dist/nuvler.js"
8
8
  },
9
9
  "main": "./dist/nuvler.js",
10
10
  "exports": {
@@ -20,8 +20,8 @@
20
20
  "typecheck": "tsc -p tsconfig.json --noEmit"
21
21
  },
22
22
  "dependencies": {
23
- "@nuvler/theme-schema": "^1.2.0",
24
- "@nuvler/theme-sdk": "^1.2.2",
23
+ "@nuvler/theme-schema": "^1.3.0",
24
+ "@nuvler/theme-sdk": "^1.3.1",
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.2",
13
+ "@nuvler/theme-sdk": "1.3.1",
14
14
  "react": "19.2.8",
15
15
  "react-dom": "19.2.8"
16
16
  },
@@ -15,30 +15,20 @@ img {
15
15
  max-width: 100%;
16
16
  }
17
17
 
18
- .nuvler-platform-footer {
19
- position: relative;
20
- z-index: 1;
21
- display: flex;
22
- min-height: 76px;
18
+ .nuvler-platform-brand {
19
+ display: inline-flex;
23
20
  align-items: center;
24
21
  justify-content: center;
25
- border-top: 1px solid rgb(255 255 255 / 10%);
26
- background: #0b1220;
27
- padding: 20px 24px;
22
+ margin-left: auto;
28
23
  }
29
24
 
30
- .nuvler-platform-footer img {
25
+ .nuvler-platform-brand img {
31
26
  width: 132px;
32
27
  height: auto;
33
28
  }
34
29
 
35
30
  @media (max-width: 640px) {
36
- .nuvler-platform-footer {
37
- min-height: 68px;
38
- padding-block: 18px;
39
- }
40
-
41
- .nuvler-platform-footer img {
31
+ .nuvler-platform-brand img {
42
32
  width: 116px;
43
33
  }
44
34
  }