@nuvler/cli 0.5.17 → 0.5.18
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/dist/api/theme-context.js.map +1 -1
- package/dist/commands/theme/create.js +1 -1
- package/dist/nuvler.js +10 -1
- package/dist/nuvler.js.map +1 -1
- package/dist/templates/nuvler-atelier/package.json +2 -2
- package/dist/templates/nuvler-default/README.md +4 -4
- package/dist/templates/nuvler-default/nuvler.theme.json +1 -1
- package/dist/templates/nuvler-default/package.json +2 -2
- package/dist/templates/nuvler-default/src/catalog-filters.tsx +169 -0
- package/dist/templates/nuvler-default/src/interaction-colors.ts +49 -0
- package/dist/templates/nuvler-default/src/kit-composition.ts +15 -0
- package/dist/templates/nuvler-default/src/product-detail-interactive.tsx +24 -12
- package/dist/templates/nuvler-default/src/server-shell.tsx +21 -3
- package/dist/templates/nuvler-default/src/theme-component.tsx +58 -23
- package/dist/templates/nuvler-default/src/theme.css +304 -1
- package/dist/templates/nuvler-default/src/whatsapp-message.ts +82 -0
- package/dist/templates/nuvler-default/test/catalog-filters.test.mjs +44 -0
- package/dist/templates/nuvler-default/test/interaction-colors.test.mjs +74 -0
- package/dist/templates/nuvler-default/test/kit-composition.test.mjs +28 -0
- package/dist/templates/nuvler-default/test/kit-detail.test.mjs +3 -3
- package/dist/templates/nuvler-default/test/whatsapp-message.test.mjs +126 -0
- package/dist/templates/starter/package.json +2 -2
- package/package.json +3 -3
- package/preview-host/package.json +1 -1
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@nuvler/theme-sdk": "^1.4.
|
|
16
|
+
"@nuvler/theme-sdk": "^1.4.8"
|
|
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.18",
|
|
23
23
|
"@types/react": "^19.0.0",
|
|
24
24
|
"react": "^19.0.0",
|
|
25
25
|
"typescript": "^5.9.0"
|
|
@@ -66,16 +66,16 @@ Para compilar, gerar o artefato ou publicar, execute na raiz do tooling:
|
|
|
66
66
|
```bash
|
|
67
67
|
npm run pack:cli
|
|
68
68
|
npm run pack:default
|
|
69
|
-
npm publish ./artifacts/nuvler-cli-0.5.13.tgz --access public
|
|
70
|
-
npm publish ./artifacts/nuvler-theme-default-1.1.7.tgz --access public
|
|
71
69
|
|
|
72
70
|
node packages/cli/dist/nuvler.js theme build --theme themes/nuvler-default
|
|
73
71
|
npm run pack:theme -- nuvler-default
|
|
74
72
|
node packages/cli/dist/nuvler.js theme publish --theme themes/nuvler-default --official
|
|
75
73
|
```
|
|
76
74
|
|
|
77
|
-
O pacote npm contém o renderer local e o CSS.
|
|
78
|
-
|
|
75
|
+
O pacote npm contém o renderer local e o CSS. As versões e a ordem de
|
|
76
|
+
publicação dos pacotes estão no [guia do monorepo](../../README.md#publicação-dos-pacotes-npm).
|
|
77
|
+
O artefato do Theme Registry é gerado separadamente como
|
|
78
|
+
`artifacts/nuvler-default-<versão>.nuvler-theme.tgz`.
|
|
79
79
|
|
|
80
80
|
Exemplo no App Router:
|
|
81
81
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuvler/theme-default",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.23",
|
|
4
4
|
"description": "Tema padrão oficial da Nuvler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"react": "^19.0.0"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@nuvler/theme-sdk": "^1.4.
|
|
68
|
+
"@nuvler/theme-sdk": "^1.4.8"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/react": "^19.0.0",
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useId, useRef, useState, type ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
export function CatalogFilters({
|
|
6
|
+
children,
|
|
7
|
+
total,
|
|
8
|
+
activeCount,
|
|
9
|
+
resetHref,
|
|
10
|
+
}: {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
total: number;
|
|
13
|
+
activeCount: number;
|
|
14
|
+
resetHref: string;
|
|
15
|
+
}) {
|
|
16
|
+
const [open, setOpen] = useState(false);
|
|
17
|
+
const panel = useRef<HTMLElement>(null);
|
|
18
|
+
const trigger = useRef<HTMLButtonElement>(null);
|
|
19
|
+
const close = useRef<HTMLButtonElement>(null);
|
|
20
|
+
const panelId = useId();
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!open) return;
|
|
24
|
+
const previous = document.body.style.overflow;
|
|
25
|
+
const opener = trigger.current;
|
|
26
|
+
document.body.style.overflow = "hidden";
|
|
27
|
+
const frame = requestAnimationFrame(() => close.current?.focus());
|
|
28
|
+
const desktop = window.matchMedia("(min-width: 801px)");
|
|
29
|
+
const resize = () => {
|
|
30
|
+
if (desktop.matches) setOpen(false);
|
|
31
|
+
};
|
|
32
|
+
desktop.addEventListener("change", resize);
|
|
33
|
+
return () => {
|
|
34
|
+
cancelAnimationFrame(frame);
|
|
35
|
+
document.body.style.overflow = previous;
|
|
36
|
+
desktop.removeEventListener("change", resize);
|
|
37
|
+
opener?.focus();
|
|
38
|
+
};
|
|
39
|
+
}, [open]);
|
|
40
|
+
|
|
41
|
+
function apply() {
|
|
42
|
+
const form =
|
|
43
|
+
panel.current?.querySelector<HTMLFormElement>(
|
|
44
|
+
".catalog-variant-filters",
|
|
45
|
+
) ??
|
|
46
|
+
panel.current?.querySelector<HTMLFormElement>(".catalog-filter-form");
|
|
47
|
+
if (!form) return;
|
|
48
|
+
const search = panel.current?.querySelector<HTMLInputElement>(
|
|
49
|
+
'input[type="search"][name="busca"]',
|
|
50
|
+
);
|
|
51
|
+
if (search && !form.contains(search)) {
|
|
52
|
+
let field = form.querySelector<HTMLInputElement>('input[name="busca"]');
|
|
53
|
+
if (!field) {
|
|
54
|
+
field = document.createElement("input");
|
|
55
|
+
field.type = "hidden";
|
|
56
|
+
field.name = "busca";
|
|
57
|
+
form.appendChild(field);
|
|
58
|
+
}
|
|
59
|
+
field.value = search.value;
|
|
60
|
+
}
|
|
61
|
+
form.requestSubmit();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
className="catalog-filter-container"
|
|
67
|
+
data-filters-open={open || undefined}
|
|
68
|
+
>
|
|
69
|
+
<div className="catalog-mobile-toolbar">
|
|
70
|
+
<span>
|
|
71
|
+
{total} {total === 1 ? "produto" : "produtos"}
|
|
72
|
+
</span>
|
|
73
|
+
<button
|
|
74
|
+
ref={trigger}
|
|
75
|
+
type="button"
|
|
76
|
+
aria-expanded={open}
|
|
77
|
+
aria-controls={panelId}
|
|
78
|
+
onClick={() => setOpen(true)}
|
|
79
|
+
>
|
|
80
|
+
<svg viewBox="0 0 24 24" aria-hidden="true">
|
|
81
|
+
<path d="M4 7h16M4 17h16M8 4v6m8 4v6" />
|
|
82
|
+
</svg>
|
|
83
|
+
Filtros
|
|
84
|
+
{activeCount > 0 && (
|
|
85
|
+
<span className="catalog-filter-count">{activeCount}</span>
|
|
86
|
+
)}
|
|
87
|
+
</button>
|
|
88
|
+
</div>
|
|
89
|
+
{open && (
|
|
90
|
+
<div
|
|
91
|
+
className="catalog-filter-backdrop"
|
|
92
|
+
aria-hidden="true"
|
|
93
|
+
onClick={() => setOpen(false)}
|
|
94
|
+
/>
|
|
95
|
+
)}
|
|
96
|
+
<aside
|
|
97
|
+
ref={panel}
|
|
98
|
+
id={panelId}
|
|
99
|
+
className="category-filter catalog-filters"
|
|
100
|
+
role={open ? "dialog" : undefined}
|
|
101
|
+
aria-modal={open || undefined}
|
|
102
|
+
aria-label="Filtros do catálogo"
|
|
103
|
+
onSubmitCapture={(event) => {
|
|
104
|
+
if (
|
|
105
|
+
open &&
|
|
106
|
+
(event.target as HTMLFormElement).classList.contains(
|
|
107
|
+
"catalog-filter-form",
|
|
108
|
+
) &&
|
|
109
|
+
panel.current?.querySelector(".catalog-variant-filters")
|
|
110
|
+
) {
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
event.stopPropagation();
|
|
113
|
+
apply();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
setOpen(false);
|
|
117
|
+
}}
|
|
118
|
+
onClickCapture={(event) => {
|
|
119
|
+
if ((event.target as Element).closest("a[href]")) setOpen(false);
|
|
120
|
+
}}
|
|
121
|
+
onKeyDown={(event) => {
|
|
122
|
+
if (!open) return;
|
|
123
|
+
if (event.key === "Escape") {
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
setOpen(false);
|
|
126
|
+
}
|
|
127
|
+
if (event.key !== "Tab") return;
|
|
128
|
+
const items = [
|
|
129
|
+
...(panel.current?.querySelectorAll<HTMLElement>(
|
|
130
|
+
'a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), [tabindex="0"]',
|
|
131
|
+
) ?? []),
|
|
132
|
+
].filter((item) => item.getClientRects().length > 0);
|
|
133
|
+
const first = items[0];
|
|
134
|
+
const last = items.at(-1);
|
|
135
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
last?.focus();
|
|
138
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
139
|
+
event.preventDefault();
|
|
140
|
+
first?.focus();
|
|
141
|
+
}
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
144
|
+
<div className="catalog-filter-mobile-heading">
|
|
145
|
+
<strong>Filtrar produtos</strong>
|
|
146
|
+
<button
|
|
147
|
+
ref={close}
|
|
148
|
+
type="button"
|
|
149
|
+
aria-label="Fechar filtros"
|
|
150
|
+
onClick={() => setOpen(false)}
|
|
151
|
+
>
|
|
152
|
+
×
|
|
153
|
+
</button>
|
|
154
|
+
</div>
|
|
155
|
+
<div className="catalog-filter-body">{children}</div>
|
|
156
|
+
<div className="catalog-filter-mobile-actions">
|
|
157
|
+
<a href={resetHref}>Limpar</a>
|
|
158
|
+
<button
|
|
159
|
+
type="button"
|
|
160
|
+
className="button button-primary"
|
|
161
|
+
onClick={apply}
|
|
162
|
+
>
|
|
163
|
+
Ver resultados
|
|
164
|
+
</button>
|
|
165
|
+
</div>
|
|
166
|
+
</aside>
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ThemeSiteColors } from "@nuvler/theme-sdk";
|
|
2
|
+
|
|
3
|
+
/** Keep existing tokens as defaults; isolate component overrides from other surfaces. */
|
|
4
|
+
export function interactionColorVariables(colors: ThemeSiteColors) {
|
|
5
|
+
const surface = colors.surface ?? "#ffffff";
|
|
6
|
+
const text = colors.text;
|
|
7
|
+
return {
|
|
8
|
+
"--mobile-menu-text":
|
|
9
|
+
colors.mobileMenuText ?? colors.headerText ?? text,
|
|
10
|
+
"--mobile-menu-hover": `color-mix(in srgb, ${colors.mobileMenuText ?? colors.headerText ?? text}, transparent 88%)`,
|
|
11
|
+
"--search-toggle-background": colors.searchButtonBackground ?? "transparent",
|
|
12
|
+
"--search-toggle-text":
|
|
13
|
+
colors.searchButtonText ?? colors.headerText ?? text,
|
|
14
|
+
"--search-toggle-hover": colors.searchButtonBackground
|
|
15
|
+
? `color-mix(in srgb, ${colors.searchButtonBackground}, ${colors.searchButtonText ?? "#ffffff"} 12%)`
|
|
16
|
+
: (colors.surfaceAlt ?? "#f4f7f3"),
|
|
17
|
+
"--search-background": colors.searchBackground ?? surface,
|
|
18
|
+
"--search-text": colors.searchText ?? text,
|
|
19
|
+
"--search-button-background":
|
|
20
|
+
colors.searchButtonBackground ?? colors.secondary,
|
|
21
|
+
"--search-button-text": colors.searchButtonText ?? "#ffffff",
|
|
22
|
+
"--search-muted": colors.searchText
|
|
23
|
+
? `color-mix(in srgb, ${colors.searchText}, transparent 25%)`
|
|
24
|
+
: (colors.textMuted ?? "#657068"),
|
|
25
|
+
"--search-hover":
|
|
26
|
+
colors.searchBackground || colors.searchText
|
|
27
|
+
? `color-mix(in srgb, ${colors.searchBackground ?? surface}, ${colors.searchText ?? text} 8%)`
|
|
28
|
+
: (colors.surfaceAlt ?? "#f4f7f3"),
|
|
29
|
+
"--cart-close-background":
|
|
30
|
+
colors.cartBackground || colors.cartText
|
|
31
|
+
? `color-mix(in srgb, ${colors.cartText ?? text}, ${colors.cartBackground ?? surface} 95%)`
|
|
32
|
+
: colors.background,
|
|
33
|
+
"--search-border":
|
|
34
|
+
colors.searchBackground || colors.searchText
|
|
35
|
+
? `color-mix(in srgb, ${colors.searchText ?? text}, transparent 80%)`
|
|
36
|
+
: (colors.border ?? "#dce3dc"),
|
|
37
|
+
"--cart-button-background": colors.cartButtonBackground ?? surface,
|
|
38
|
+
"--cart-button-text": colors.cartButtonText ?? text,
|
|
39
|
+
"--cart-background": colors.cartBackground ?? surface,
|
|
40
|
+
"--cart-text": colors.cartText ?? text,
|
|
41
|
+
"--cart-muted": colors.cartText
|
|
42
|
+
? `color-mix(in srgb, ${colors.cartText}, transparent 25%)`
|
|
43
|
+
: (colors.textMuted ?? "#657068"),
|
|
44
|
+
"--cart-border":
|
|
45
|
+
colors.cartBackground || colors.cartText
|
|
46
|
+
? `color-mix(in srgb, ${colors.cartText ?? text}, transparent 80%)`
|
|
47
|
+
: (colors.border ?? "#dce3dc"),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
kitCompositionText as groupedCompositionText,
|
|
3
|
+
type ThemeCartItem,
|
|
4
|
+
} from "@nuvler/theme-sdk";
|
|
5
|
+
|
|
6
|
+
/** The default theme displays legacy kit choices without a generated prefix. */
|
|
7
|
+
export function kitCompositionText(
|
|
8
|
+
item: Pick<ThemeCartItem, "kitSize" | "kitGroups" | "composition">,
|
|
9
|
+
): string {
|
|
10
|
+
if (item.kitGroups?.length) return groupedCompositionText(item);
|
|
11
|
+
if (!item.kitSize) return "";
|
|
12
|
+
return (item.composition ?? [])
|
|
13
|
+
.map((part) => `${part.name}: ${part.quantity}`)
|
|
14
|
+
.join("; ");
|
|
15
|
+
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
formatWhatsappRequest,
|
|
5
|
+
whatsappRequestLabel,
|
|
6
|
+
whatsappRequestUrl,
|
|
7
|
+
} from "./whatsapp-message.js";
|
|
8
|
+
|
|
3
9
|
import {
|
|
4
10
|
createContext,
|
|
5
11
|
useEffect,
|
|
@@ -12,7 +18,6 @@ import {
|
|
|
12
18
|
} from "react";
|
|
13
19
|
import {
|
|
14
20
|
verifyKitCart,
|
|
15
|
-
kitCompositionText,
|
|
16
21
|
productUrl as relativeProductUrl,
|
|
17
22
|
type ProductDetailProps,
|
|
18
23
|
type ThemeCartItem,
|
|
@@ -89,7 +94,7 @@ export function ProductCardAction({
|
|
|
89
94
|
className="button button-primary button-block product-card-action"
|
|
90
95
|
onClick={() => onAddToCart(item)}
|
|
91
96
|
>
|
|
92
|
-
Adicionar ao
|
|
97
|
+
Adicionar ao Carrinho
|
|
93
98
|
</button>
|
|
94
99
|
);
|
|
95
100
|
}
|
|
@@ -222,14 +227,21 @@ export function ProductDetailInteractive({
|
|
|
222
227
|
"";
|
|
223
228
|
const unitPrice =
|
|
224
229
|
variant && !kitSize ? null : (product.promotionalPrice ?? product.price);
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
const message = formatWhatsappRequest(
|
|
231
|
+
[
|
|
232
|
+
{
|
|
233
|
+
...kitItem,
|
|
234
|
+
kitSize: kitSize || null,
|
|
235
|
+
variantName: kitSize ? "" : variantDescription,
|
|
236
|
+
sku: kitSize ? product.sku : variant?.sku || product.sku,
|
|
237
|
+
unitPrice: showPrices ? unitPrice : null,
|
|
238
|
+
productUrl: productUrl ?? undefined,
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
showPrices,
|
|
242
|
+
typeof window === "undefined" ? undefined : window.location.origin,
|
|
243
|
+
);
|
|
244
|
+
const whatsapp = phone ? whatsappRequestUrl(phone, message) : null;
|
|
233
245
|
const hasVariants = product.variantOptions.length > 0;
|
|
234
246
|
const outOfStock = product.stockQuantity === 0;
|
|
235
247
|
const canPurchase =
|
|
@@ -514,7 +526,7 @@ export function ProductDetailInteractive({
|
|
|
514
526
|
})
|
|
515
527
|
}
|
|
516
528
|
>
|
|
517
|
-
Adicionar ao
|
|
529
|
+
Adicionar ao Carrinho
|
|
518
530
|
</button>
|
|
519
531
|
)}
|
|
520
532
|
{canPurchase && whatsapp && (
|
|
@@ -537,7 +549,7 @@ export function ProductDetailInteractive({
|
|
|
537
549
|
target="_blank"
|
|
538
550
|
rel="noreferrer"
|
|
539
551
|
>
|
|
540
|
-
|
|
552
|
+
{whatsappRequestLabel}
|
|
541
553
|
</a>
|
|
542
554
|
)}
|
|
543
555
|
{canPurchase && !whatsapp && contact?.email && (
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { interactionColorVariables } from "./interaction-colors.js";
|
|
1
2
|
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
ThemeCategory,
|
|
5
|
+
ThemeNavigationHeaderButton,
|
|
6
|
+
ThemeNavigationItem,
|
|
7
|
+
ThemePageSummary,
|
|
8
|
+
ThemeSite,
|
|
9
|
+
} from "@nuvler/theme-sdk";
|
|
3
10
|
|
|
4
11
|
import { Footer } from "./footer.js";
|
|
5
12
|
import { Header } from "./header.js";
|
|
@@ -42,9 +49,20 @@ export function NuvlerDefaultShell({
|
|
|
42
49
|
colors: { ...nuvlerDefaultTokens.colors, ...configured?.colors },
|
|
43
50
|
layout: { ...nuvlerDefaultTokens.layout, ...configured?.layout },
|
|
44
51
|
};
|
|
45
|
-
const containerWidth = Math.min(
|
|
46
|
-
|
|
52
|
+
const containerWidth = Math.min(
|
|
53
|
+
1600,
|
|
54
|
+
Math.max(
|
|
55
|
+
960,
|
|
56
|
+
Number(tokens.layout.containerWidth) ||
|
|
57
|
+
nuvlerDefaultTokens.layout.containerWidth,
|
|
58
|
+
),
|
|
59
|
+
);
|
|
60
|
+
const borderRadius = Math.min(
|
|
61
|
+
32,
|
|
62
|
+
Math.max(0, Number(tokens.layout.borderRadius) || 0),
|
|
63
|
+
);
|
|
47
64
|
const style = {
|
|
65
|
+
...interactionColorVariables(tokens.colors),
|
|
48
66
|
"--color-primary": tokens.colors.primary,
|
|
49
67
|
"--color-primary-text": tokens.colors.primaryText,
|
|
50
68
|
"--color-secondary": tokens.colors.secondary,
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { interactionColorVariables } from "./interaction-colors.js";
|
|
4
|
+
import { CatalogFilters } from "./catalog-filters.js";
|
|
5
|
+
import { kitCompositionText } from "./kit-composition.js";
|
|
6
|
+
import {
|
|
7
|
+
formatWhatsappRequest,
|
|
8
|
+
whatsappRequestLabel,
|
|
9
|
+
whatsappRequestUrl,
|
|
10
|
+
} from "./whatsapp-message.js";
|
|
11
|
+
|
|
3
12
|
import {
|
|
4
13
|
useEffect,
|
|
5
14
|
useMemo,
|
|
@@ -10,7 +19,6 @@ import {
|
|
|
10
19
|
import {
|
|
11
20
|
productUrl,
|
|
12
21
|
themeCartKey,
|
|
13
|
-
kitCompositionText,
|
|
14
22
|
verifyKitCart,
|
|
15
23
|
type NuvlerStoreThemeDefinition,
|
|
16
24
|
type ThemeCartItem,
|
|
@@ -405,9 +413,7 @@ export function createNuvlerDefaultRuntime(
|
|
|
405
413
|
null,
|
|
406
414
|
);
|
|
407
415
|
const [hydratedCartKey, setHydratedCartKey] = useState<string | null>(null);
|
|
408
|
-
const cartToastTimeout = useRef<
|
|
409
|
-
typeof window.setTimeout
|
|
410
|
-
> | null>(null);
|
|
416
|
+
const cartToastTimeout = useRef<number | null>(null);
|
|
411
417
|
const cartStorageKey = `nuvler:cart:${context.store.slug}`;
|
|
412
418
|
|
|
413
419
|
useEffect(() => {
|
|
@@ -475,6 +481,7 @@ export function createNuvlerDefaultRuntime(
|
|
|
475
481
|
Math.max(0, Number(tokens.layout.borderRadius) || 0),
|
|
476
482
|
);
|
|
477
483
|
const style = {
|
|
484
|
+
...interactionColorVariables(tokens.colors),
|
|
478
485
|
"--color-primary": tokens.colors.primary,
|
|
479
486
|
"--color-primary-text": tokens.colors.primaryText,
|
|
480
487
|
"--color-secondary": tokens.colors.secondary,
|
|
@@ -505,24 +512,19 @@ export function createNuvlerDefaultRuntime(
|
|
|
505
512
|
const hasCompletePrices =
|
|
506
513
|
cartItems.length > 0 &&
|
|
507
514
|
cartItems.every(({ unitPrice }) => typeof unitPrice === "number");
|
|
508
|
-
const cartMessage = useMemo(
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
showPrices && hasCompletePrices
|
|
518
|
-
? `\n\nTotal estimado: ${money(cartTotal)}`
|
|
519
|
-
: "";
|
|
520
|
-
return `Olá! Gostaria de solicitar um orçamento para os itens abaixo:\n\n${lines.join("\n\n")}${summary}`;
|
|
521
|
-
}, [cartItems, cartTotal, hasCompletePrices, showPrices]);
|
|
515
|
+
const cartMessage = useMemo(
|
|
516
|
+
() =>
|
|
517
|
+
formatWhatsappRequest(
|
|
518
|
+
cartItems,
|
|
519
|
+
showPrices,
|
|
520
|
+
typeof window === "undefined" ? undefined : window.location.origin,
|
|
521
|
+
),
|
|
522
|
+
[cartItems, showPrices],
|
|
523
|
+
);
|
|
522
524
|
const whatsapp = site.settings?.contact.whatsapp?.replace(/\D/g, "");
|
|
523
525
|
const checkoutUrl =
|
|
524
526
|
whatsapp && cartItems.length
|
|
525
|
-
?
|
|
527
|
+
? whatsappRequestUrl(whatsapp, cartMessage)
|
|
526
528
|
: null;
|
|
527
529
|
const addToCart = (item: ThemeCartItem) => {
|
|
528
530
|
const key = themeCartKey(item);
|
|
@@ -610,7 +612,21 @@ export function createNuvlerDefaultRuntime(
|
|
|
610
612
|
</div>
|
|
611
613
|
</section>
|
|
612
614
|
<div className="store-container catalog-layout">
|
|
613
|
-
<
|
|
615
|
+
<CatalogFilters
|
|
616
|
+
key={JSON.stringify([
|
|
617
|
+
route.categoryPath,
|
|
618
|
+
route.search,
|
|
619
|
+
route.variants,
|
|
620
|
+
route.pagination.page,
|
|
621
|
+
])}
|
|
622
|
+
total={route.pagination.total}
|
|
623
|
+
activeCount={route.variants.length + (route.search ? 1 : 0)}
|
|
624
|
+
resetHref={
|
|
625
|
+
route.categoryPath.length
|
|
626
|
+
? `/${route.categoryPath.join("/")}`
|
|
627
|
+
: "/produtos"
|
|
628
|
+
}
|
|
629
|
+
>
|
|
614
630
|
<form
|
|
615
631
|
action={
|
|
616
632
|
route.categoryPath.length
|
|
@@ -619,6 +635,14 @@ export function createNuvlerDefaultRuntime(
|
|
|
619
635
|
}
|
|
620
636
|
className="catalog-filter-form"
|
|
621
637
|
>
|
|
638
|
+
{route.variants.map((token) => (
|
|
639
|
+
<input
|
|
640
|
+
key={token}
|
|
641
|
+
type="hidden"
|
|
642
|
+
name="variante"
|
|
643
|
+
value={token}
|
|
644
|
+
/>
|
|
645
|
+
))}
|
|
622
646
|
<label htmlFor="preview-catalog-search">
|
|
623
647
|
Buscar no catálogo
|
|
624
648
|
</label>
|
|
@@ -636,7 +660,14 @@ export function createNuvlerDefaultRuntime(
|
|
|
636
660
|
</div>
|
|
637
661
|
</form>
|
|
638
662
|
{route.facets.length > 0 && (
|
|
639
|
-
<form
|
|
663
|
+
<form
|
|
664
|
+
action={
|
|
665
|
+
route.categoryPath.length
|
|
666
|
+
? `/${route.categoryPath.join("/")}`
|
|
667
|
+
: "/produtos"
|
|
668
|
+
}
|
|
669
|
+
className="catalog-variant-filters"
|
|
670
|
+
>
|
|
640
671
|
{route.search && (
|
|
641
672
|
<input type="hidden" name="busca" value={route.search} />
|
|
642
673
|
)}
|
|
@@ -674,7 +705,7 @@ export function createNuvlerDefaultRuntime(
|
|
|
674
705
|
</button>
|
|
675
706
|
</form>
|
|
676
707
|
)}
|
|
677
|
-
</
|
|
708
|
+
</CatalogFilters>
|
|
678
709
|
<section className="catalog-results">
|
|
679
710
|
<ProductGrid
|
|
680
711
|
products={route.products}
|
|
@@ -692,6 +723,8 @@ export function createNuvlerDefaultRuntime(
|
|
|
692
723
|
className={
|
|
693
724
|
route.pagination.hasPreviousPage ? "" : "disabled"
|
|
694
725
|
}
|
|
726
|
+
aria-disabled={!route.pagination.hasPreviousPage}
|
|
727
|
+
tabIndex={route.pagination.hasPreviousPage ? undefined : -1}
|
|
695
728
|
href={catalogHref(
|
|
696
729
|
route,
|
|
697
730
|
Math.max(1, route.pagination.page - 1),
|
|
@@ -711,6 +744,8 @@ export function createNuvlerDefaultRuntime(
|
|
|
711
744
|
</div>
|
|
712
745
|
<a
|
|
713
746
|
className={route.pagination.hasNextPage ? "" : "disabled"}
|
|
747
|
+
aria-disabled={!route.pagination.hasNextPage}
|
|
748
|
+
tabIndex={route.pagination.hasNextPage ? undefined : -1}
|
|
714
749
|
href={catalogHref(
|
|
715
750
|
route,
|
|
716
751
|
Math.min(
|
|
@@ -1060,7 +1095,7 @@ export function createNuvlerDefaultRuntime(
|
|
|
1060
1095
|
target="_blank"
|
|
1061
1096
|
rel="noreferrer"
|
|
1062
1097
|
>
|
|
1063
|
-
|
|
1098
|
+
{whatsappRequestLabel}
|
|
1064
1099
|
</a>
|
|
1065
1100
|
) : (
|
|
1066
1101
|
<p className="cart-warning">
|