@nuvler/cli 0.5.1 → 0.5.2
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.
- package/README.md +2 -2
- package/dist/commands/theme/create.js +2 -2
- package/dist/index.js +1 -1
- package/dist/nuvler.js +33 -4
- package/dist/nuvler.js.map +1 -1
- package/dist/templates/nuvler-atelier/nuvler.theme.json +2 -2
- package/dist/templates/nuvler-atelier/package.json +3 -3
- package/dist/templates/nuvler-default/nuvler.theme.json +2 -2
- package/dist/templates/nuvler-default/package.json +2 -2
- package/dist/templates/starter/nuvler.theme.json +1 -1
- package/dist/templates/starter/package.json +2 -2
- package/package.json +3 -3
- package/preview-host/package.json +1 -1
- package/preview-host/src/main.tsx +7 -2
- package/preview-host/vendor/theme-runtime/default-theme.tsx +35 -11
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuvler-theme-nuvler-atelier",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
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.3.
|
|
16
|
+
"@nuvler/theme-sdk": "^1.3.2"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": "^19.0.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@nuvler/cli": "^0.5.
|
|
22
|
+
"@nuvler/cli": "^0.5.2",
|
|
23
23
|
"@types/react": "^19.0.0",
|
|
24
24
|
"react": "^19.0.0",
|
|
25
25
|
"typescript": "^5.9.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuvler/theme-default",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Tema padrão oficial da Nuvler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"react": "^19.0.0"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@nuvler/theme-sdk": "^1.3.
|
|
67
|
+
"@nuvler/theme-sdk": "^1.3.2"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/react": "^19.0.0",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@nuvler/theme-sdk": "^1.3.
|
|
16
|
+
"@nuvler/theme-sdk": "^1.3.2"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": "^19.0.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@nuvler/cli": "^0.5.
|
|
22
|
+
"@nuvler/cli": "^0.5.2",
|
|
23
23
|
"@types/react": "^19.0.0",
|
|
24
24
|
"react": "^19.0.0",
|
|
25
25
|
"typescript": "^5.9.0"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuvler/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "CLI oficial para criação, validação, preview e empacotamento de temas Nuvler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@nuvler/theme-schema": "^1.3.
|
|
24
|
-
"@nuvler/theme-sdk": "^1.3.
|
|
23
|
+
"@nuvler/theme-schema": "^1.3.1",
|
|
24
|
+
"@nuvler/theme-sdk": "^1.3.2",
|
|
25
25
|
"@vitejs/plugin-react": "^6.0.5",
|
|
26
26
|
"commander": "^15.0.0",
|
|
27
27
|
"react": "19.2.8",
|
|
@@ -87,8 +87,7 @@ function routeFromLocalData(url: URL): ThemeRoute | null {
|
|
|
87
87
|
return item ? { type: "editorial-detail", basePath: group.basePath, item } : { type: "not-found", pathname: url.pathname };
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
return page ? { type: "page", title: page.title } : null;
|
|
90
|
+
return null;
|
|
92
91
|
}
|
|
93
92
|
|
|
94
93
|
function PreviewApp() {
|
|
@@ -112,6 +111,12 @@ function PreviewApp() {
|
|
|
112
111
|
if (currentRequest === requestId.current) setRoute({ type: "product", product });
|
|
113
112
|
return;
|
|
114
113
|
}
|
|
114
|
+
if (url.pathname.split("/").filter(Boolean).length === 1) {
|
|
115
|
+
const slug = decodeURIComponent(url.pathname.slice(1));
|
|
116
|
+
const page = await previewApi<{ title: string; slug: string; content: { schemaVersion: 1; time?: number; version?: string; blocks: Array<{ id?: string; type: string; data: Record<string, unknown> }> } }>(`pages/${encodeURIComponent(slug)}`);
|
|
117
|
+
if (currentRequest === requestId.current) setRoute({ type: "page", title: page.title, slug: page.slug, content: page.content });
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
115
120
|
if (url.pathname === "/produtos" || url.pathname.startsWith("/categoria/")) {
|
|
116
121
|
const categoryPath = url.pathname.startsWith("/categoria/")
|
|
117
122
|
? url.pathname.slice("/categoria/".length).split("/").filter(Boolean).map(decodeURIComponent)
|
|
@@ -385,15 +385,20 @@ function dataRecords(data: Record<string, unknown>, field: string): Record<strin
|
|
|
385
385
|
: [];
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
+
function formatWhatsapp(value: string): string {
|
|
389
|
+
const digits = value.replace(/\D/g, "").slice(0, 11);
|
|
390
|
+
if (!digits) return "";
|
|
391
|
+
if (digits.length <= 2) return `(${digits}`;
|
|
392
|
+
const number = digits.slice(2);
|
|
393
|
+
return number.length <= 5
|
|
394
|
+
? `(${digits.slice(0, 2)}) ${number}`
|
|
395
|
+
: `(${digits.slice(0, 2)}) ${number.slice(0, 5)}-${number.slice(5)}`;
|
|
396
|
+
}
|
|
397
|
+
|
|
388
398
|
function ContactFormComponent({ section, sdk }: ThemeSectionRendererProps) {
|
|
389
399
|
const props = dataRecord(section.data, "props");
|
|
390
400
|
const configuredFields = dataRecords(props, "fields");
|
|
391
|
-
const fields = configuredFields
|
|
392
|
-
{ key: "name", label: "Nome", type: "text", required: true },
|
|
393
|
-
{ key: "email", label: "E-mail", type: "email", required: true },
|
|
394
|
-
{ key: "phone", label: "Telefone", type: "tel", required: false },
|
|
395
|
-
{ key: "message", label: "Mensagem", type: "textarea", required: true },
|
|
396
|
-
];
|
|
401
|
+
const fields = configuredFields;
|
|
397
402
|
const [status, setStatus] = useState<"idle" | "sending" | "success" | "error">("idle");
|
|
398
403
|
const [error, setError] = useState("");
|
|
399
404
|
|
|
@@ -458,7 +463,7 @@ function ContactFormComponent({ section, sdk }: ThemeSectionRendererProps) {
|
|
|
458
463
|
<span>{label}{required && <small aria-hidden="true"> *</small>}</span>
|
|
459
464
|
{type === "textarea"
|
|
460
465
|
? <textarea name={key} placeholder={dataString(field, "placeholder")} required={required} rows={5} />
|
|
461
|
-
: <input name={key} placeholder={dataString(field, "placeholder")} required={required} type={["email", "tel", "url", "number"].includes(type) ? type : "text"} />}
|
|
466
|
+
: <input name={key} placeholder={dataString(field, "placeholder")} required={required} type={["email", "tel", "url", "number"].includes(type) ? type : "text"} maxLength={dataString(field, "mask") === "whatsapp-br" ? 15 : undefined} onInput={dataString(field, "mask") === "whatsapp-br" ? (event) => { event.currentTarget.value = formatWhatsapp(event.currentTarget.value); } : undefined} />}
|
|
462
467
|
</label>;
|
|
463
468
|
})}
|
|
464
469
|
<div className="contact-form-wide">
|
|
@@ -472,6 +477,24 @@ function ContactFormComponent({ section, sdk }: ThemeSectionRendererProps) {
|
|
|
472
477
|
</div></section>;
|
|
473
478
|
}
|
|
474
479
|
|
|
480
|
+
function PageContent({ route, context, adapters, sdk }: {
|
|
481
|
+
route: Extract<ThemeRoute, { type: "page" }>;
|
|
482
|
+
context: ThemeContext;
|
|
483
|
+
adapters: ThemeRuntimeAdapters;
|
|
484
|
+
sdk?: ThemeRuntimeSdk;
|
|
485
|
+
}) {
|
|
486
|
+
return <main className="store-section"><article className="store-container editorial-content">
|
|
487
|
+
<h1>{route.title}</h1>
|
|
488
|
+
{route.content.blocks.map((block, index) => {
|
|
489
|
+
if (block.type === "theme-component") return <ThemeComponentSection key={block.id || index} section={{ id: block.id, type: "theme-component", enabled: true, order: index, data: block.data }} context={context} adapters={adapters} sdk={sdk} />;
|
|
490
|
+
if (block.type === "header") return <h2 key={block.id || index}>{plainText(dataString(block.data, "text"))}</h2>;
|
|
491
|
+
if (block.type === "paragraph") return <p key={block.id || index}>{plainText(dataString(block.data, "text"))}</p>;
|
|
492
|
+
if (block.type === "delimiter") return <hr key={block.id || index} />;
|
|
493
|
+
return null;
|
|
494
|
+
})}
|
|
495
|
+
</article></main>;
|
|
496
|
+
}
|
|
497
|
+
|
|
475
498
|
function ThemeComponentSection(props: ThemeSectionRendererProps) {
|
|
476
499
|
const { section } = props;
|
|
477
500
|
const componentKey = dataString(section.data, "componentKey");
|
|
@@ -649,11 +672,12 @@ function ProductPage({ product, context, adapters }: {
|
|
|
649
672
|
</div></main>;
|
|
650
673
|
}
|
|
651
674
|
|
|
652
|
-
function RouteContent({ route, context, adapters, home }: {
|
|
675
|
+
function RouteContent({ route, context, adapters, home, sdk }: {
|
|
653
676
|
route: ThemeRoute;
|
|
654
677
|
context: ThemeContext;
|
|
655
678
|
adapters: ThemeRuntimeAdapters;
|
|
656
679
|
home: ReactNode;
|
|
680
|
+
sdk?: ThemeRuntimeSdk;
|
|
657
681
|
}) {
|
|
658
682
|
if (route.type === "home") return home;
|
|
659
683
|
if (route.type === "loading") return <main className="not-found-page"><div className="not-found-card"><span>Carregando</span><h1>Buscando conteúdo da loja</h1></div></main>;
|
|
@@ -662,7 +686,7 @@ function RouteContent({ route, context, adapters, home }: {
|
|
|
662
686
|
if (route.type === "product") return <ProductPage adapters={adapters} context={context} product={route.product} />;
|
|
663
687
|
if (route.type === "editorial-list") return <main className="catalog-page"><section className="catalog-hero"><div className="store-container"><span>Conteúdo</span><h1>{route.title}</h1></div></section><section className="store-section"><div className="store-container"><EditorialCards adapters={adapters} basePath={route.basePath} items={route.items} /></div></section></main>;
|
|
664
688
|
if (route.type === "editorial-detail") return <main className="store-section"><article className="store-container editorial-content"><span>Conteúdo</span><h1>{route.item.title}</h1><p>{route.item.description}</p></article></main>;
|
|
665
|
-
return <
|
|
689
|
+
return <PageContent adapters={adapters} context={context} route={route} sdk={sdk} />;
|
|
666
690
|
}
|
|
667
691
|
|
|
668
692
|
function Footer({ context, adapters }: DefaultThemeProps) {
|
|
@@ -716,9 +740,9 @@ export function DefaultTheme({ context, adapters, route = { type: "home" }, sdk
|
|
|
716
740
|
const visible = context.home.content.sections.filter((section) => section.enabled).sort((a, b) => a.order - b.order);
|
|
717
741
|
const sections = visible.length ? visible : fallbackSections(context);
|
|
718
742
|
|
|
719
|
-
return <div className="store-shell nuvler-default-theme" data-theme-id="nuvler-default" data-theme-version="1.0.
|
|
743
|
+
return <div className="store-shell nuvler-default-theme" data-theme-id="nuvler-default" data-theme-version="1.0.7" style={style}>
|
|
720
744
|
<Header adapters={adapters} context={context} />
|
|
721
|
-
<div className="store-page"><RouteContent adapters={adapters} context={context} route={route} home={<main>{sections.map((section, index) => {
|
|
745
|
+
<div className="store-page"><RouteContent adapters={adapters} context={context} route={route} sdk={sdk} home={<main>{sections.map((section, index) => {
|
|
722
746
|
const Renderer = defaultSectionRegistry[section.type];
|
|
723
747
|
return Renderer ? <Renderer adapters={adapters} context={context} key={`${section.type}-${section.order}-${index}`} sdk={sdk} section={section} /> : null;
|
|
724
748
|
})}<section className="benefits-section"><div className="store-container benefits-grid">{template.benefits.map((benefit) => <div key={benefit.title}><strong>{benefit.title}</strong><span>{benefit.description}</span></div>)}</div></section></main>} /></div>
|