@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.
@@ -3600,7 +3600,13 @@ a.mini-banner-card:focus-visible {
3600
3600
  .catalog-filters {
3601
3601
  position: sticky;
3602
3602
  top: 146px;
3603
- overflow: hidden;
3603
+ box-sizing: border-box;
3604
+ max-height: calc(100vh - 162px);
3605
+ max-height: calc(100dvh - 162px);
3606
+ overflow-x: hidden;
3607
+ overflow-y: auto;
3608
+ overscroll-behavior-y: contain;
3609
+ scrollbar-gutter: stable;
3604
3610
  align-items: stretch;
3605
3611
  align-self: start;
3606
3612
  gap: 0;
@@ -3863,6 +3869,7 @@ a.mini-banner-card:focus-visible {
3863
3869
  .product-main-image {
3864
3870
  position: relative;
3865
3871
  overflow: hidden;
3872
+ aspect-ratio: auto;
3866
3873
  border: 1px solid var(--store-line);
3867
3874
  border-radius: var(--border-radius);
3868
3875
  background: var(--store-surface);
@@ -5417,7 +5424,10 @@ a.mini-banner-card:focus-visible {
5417
5424
 
5418
5425
  .catalog-filters {
5419
5426
  position: static;
5427
+ max-height: none;
5420
5428
  overflow: visible;
5429
+ overscroll-behavior-y: auto;
5430
+ scrollbar-gutter: auto;
5421
5431
  align-items: stretch;
5422
5432
  flex-direction: column;
5423
5433
  padding: 16px;
@@ -6117,3 +6127,296 @@ summary.kit-group-header:hover {
6117
6127
  gap: 4px;
6118
6128
  }
6119
6129
  }
6130
+
6131
+ /* Optional per-store search and cart colors. */
6132
+ .header-search input {
6133
+ background: var(--search-background, var(--store-surface));
6134
+ color: var(--search-text, var(--store-text));
6135
+ border-color: var(--search-border, var(--store-line));
6136
+ }
6137
+ .header-search input::placeholder {
6138
+ color: var(--search-muted, var(--store-muted));
6139
+ opacity: 1;
6140
+ }
6141
+ .header-search-toggle {
6142
+ background: var(--search-toggle-background, transparent);
6143
+ color: var(--search-toggle-text, var(--store-header-text));
6144
+ }
6145
+ .header-search-toggle:hover {
6146
+ background: var(--search-toggle-hover, var(--store-surface-alt));
6147
+ }
6148
+ .header-search button[type="submit"] {
6149
+ background: var(--search-button-background, var(--color-secondary));
6150
+ color: var(--search-button-text, #fff);
6151
+ }
6152
+ .header-search button[type="submit"]:hover {
6153
+ background: var(--search-toggle-hover, var(--store-surface-alt));
6154
+ }
6155
+ .header-search .header-search-close {
6156
+ background: transparent;
6157
+ color: var(--search-text, var(--store-text));
6158
+ }
6159
+ .header-search .header-search-close:hover {
6160
+ background: var(--search-hover, var(--store-surface-alt));
6161
+ }
6162
+ .header-search-toggle:focus-visible,
6163
+ .header-search button:focus-visible {
6164
+ outline: 2px solid currentColor;
6165
+ outline-offset: 2px;
6166
+ }
6167
+ .search-suggestions {
6168
+ --store-surface-alt: var(--search-hover);
6169
+ --store-surface: var(--search-background);
6170
+ --store-text: var(--search-text);
6171
+ --store-muted: var(--search-muted);
6172
+ --store-line: var(--search-border);
6173
+ color: var(--store-text);
6174
+ }
6175
+ .cart-button {
6176
+ background: var(--cart-button-background, var(--store-surface));
6177
+ color: var(--cart-button-text, var(--store-text));
6178
+ }
6179
+ .cart-button span {
6180
+ border-color: var(--cart-button-background, var(--store-surface));
6181
+ }
6182
+ .cart-drawer {
6183
+ --store-surface: var(--cart-background);
6184
+ --store-text: var(--cart-text);
6185
+ --store-muted: var(--cart-muted);
6186
+ --store-line: var(--cart-border);
6187
+ color: var(--store-text);
6188
+ }
6189
+ .cart-heading button {
6190
+ background: var(--cart-close-background, var(--store-background));
6191
+ }
6192
+
6193
+ .cart-quantity button {
6194
+ color: var(--cart-text, var(--store-text));
6195
+ }
6196
+
6197
+ /* The desktop sidebar and mobile dialog share one set of filter inputs. */
6198
+ .catalog-filter-container {
6199
+ display: contents;
6200
+ }
6201
+ .catalog-mobile-toolbar,
6202
+ .catalog-filter-mobile-heading,
6203
+ .catalog-filter-mobile-actions,
6204
+ .catalog-filter-backdrop {
6205
+ display: none;
6206
+ }
6207
+ .catalog-filter-body {
6208
+ width: 100%;
6209
+ min-height: 0;
6210
+ }
6211
+ @media (max-width: 800px) {
6212
+ .catalog-page .catalog-hero {
6213
+ padding: 24px 0;
6214
+ }
6215
+ .catalog-page .catalog-hero h1 {
6216
+ font-size: clamp(24px, 6vw, 32px);
6217
+ margin: 8px 0 0;
6218
+ line-height: 1.2;
6219
+ }
6220
+ .catalog-page .catalog-hero p {
6221
+ margin-top: 8px;
6222
+ font-size: 13px;
6223
+ }
6224
+ .catalog-page .catalog-layout {
6225
+ padding-top: 20px;
6226
+ padding-bottom: 36px;
6227
+ gap: 16px;
6228
+ }
6229
+ .catalog-filter-container {
6230
+ display: block;
6231
+ min-width: 0;
6232
+ }
6233
+ .catalog-mobile-toolbar {
6234
+ display: flex;
6235
+ align-items: center;
6236
+ justify-content: space-between;
6237
+ gap: 12px;
6238
+ font-size: 13px;
6239
+ color: var(--store-muted);
6240
+ }
6241
+ .catalog-mobile-toolbar > button {
6242
+ display: flex;
6243
+ align-items: center;
6244
+ gap: 8px;
6245
+ min-height: 44px;
6246
+ padding: 8px 14px;
6247
+ border: 1px solid var(--store-line);
6248
+ border-radius: 10px;
6249
+ background: var(--store-surface);
6250
+ color: var(--store-text);
6251
+ font: inherit;
6252
+ font-weight: 700;
6253
+ cursor: pointer;
6254
+ }
6255
+ .catalog-mobile-toolbar svg {
6256
+ width: 18px;
6257
+ height: 18px;
6258
+ fill: none;
6259
+ stroke: currentColor;
6260
+ stroke-width: 1.8;
6261
+ stroke-linecap: round;
6262
+ }
6263
+ .catalog-filter-count {
6264
+ display: grid;
6265
+ place-items: center;
6266
+ min-width: 22px;
6267
+ height: 22px;
6268
+ border-radius: 999px;
6269
+ background: var(--color-primary);
6270
+ color: var(--color-primary-text);
6271
+ font-size: 11px;
6272
+ }
6273
+ .catalog-filter-container > .catalog-filters {
6274
+ display: none;
6275
+ }
6276
+ .catalog-filter-container[data-filters-open] > .catalog-filters {
6277
+ display: flex;
6278
+ position: fixed;
6279
+ inset: 0 0 0 auto;
6280
+ z-index: 220;
6281
+ width: min(420px, 100%);
6282
+ height: 100dvh;
6283
+ max-height: 100dvh;
6284
+ margin: 0;
6285
+ padding: 0;
6286
+ border: 0;
6287
+ border-radius: 0;
6288
+ overflow: hidden;
6289
+ background: var(--store-surface);
6290
+ color: var(--store-text);
6291
+ }
6292
+ .catalog-filter-backdrop {
6293
+ display: block;
6294
+ position: fixed;
6295
+ inset: 0;
6296
+ z-index: 210;
6297
+ background: rgb(0 0 0 / 45%);
6298
+ }
6299
+ .catalog-filter-mobile-heading {
6300
+ display: flex;
6301
+ align-items: center;
6302
+ justify-content: space-between;
6303
+ flex-shrink: 0;
6304
+ gap: 16px;
6305
+ padding: max(16px, env(safe-area-inset-top)) 16px 16px;
6306
+ border-bottom: 1px solid var(--store-line);
6307
+ }
6308
+ .catalog-filter-mobile-heading strong {
6309
+ margin: 0;
6310
+ font-size: 17px;
6311
+ }
6312
+ .catalog-filter-mobile-heading button {
6313
+ width: 44px;
6314
+ height: 44px;
6315
+ border: 0;
6316
+ border-radius: 10px;
6317
+ background: var(--store-surface-alt);
6318
+ color: var(--store-text);
6319
+ font-size: 26px;
6320
+ cursor: pointer;
6321
+ }
6322
+ .catalog-filter-body {
6323
+ flex: 1;
6324
+ overflow-y: auto;
6325
+ overscroll-behavior-y: contain;
6326
+ padding: 18px 16px;
6327
+ }
6328
+ .catalog-filter-mobile-actions {
6329
+ display: flex;
6330
+ align-items: center;
6331
+ gap: 12px;
6332
+ flex-shrink: 0;
6333
+ padding: 14px 16px max(14px, env(safe-area-inset-bottom));
6334
+ border-top: 1px solid var(--store-line);
6335
+ }
6336
+ .catalog-filter-mobile-actions > a {
6337
+ width: auto;
6338
+ flex: 0 0 auto;
6339
+ padding: 12px;
6340
+ color: var(--store-text);
6341
+ text-decoration: underline;
6342
+ }
6343
+ .catalog-filter-mobile-actions > button {
6344
+ flex: 1;
6345
+ min-height: 44px;
6346
+ }
6347
+ .catalog-filter-body .catalog-variant-filters > button {
6348
+ display: none;
6349
+ }
6350
+ .catalog-results > .catalog-toolbar {
6351
+ display: none;
6352
+ }
6353
+ .catalog-page .catalog-results .product-grid,
6354
+ .catalog-page .catalog-results .product-grid[data-columns] {
6355
+ grid-template-columns: repeat(2, minmax(0, 1fr));
6356
+ gap: 10px;
6357
+ }
6358
+ .catalog-page .product-card {
6359
+ min-width: 0;
6360
+ }
6361
+ .catalog-page .product-card-image {
6362
+ aspect-ratio: 1;
6363
+ }
6364
+ .catalog-page .product-card-content {
6365
+ padding: 10px;
6366
+ gap: 6px;
6367
+ }
6368
+ .catalog-page .product-card h3 {
6369
+ display: -webkit-box;
6370
+ -webkit-box-orient: vertical;
6371
+ -webkit-line-clamp: 2;
6372
+ overflow: hidden;
6373
+ min-height: 2.7em;
6374
+ margin: 0;
6375
+ font-size: 13px;
6376
+ line-height: 1.35;
6377
+ }
6378
+ .catalog-page .product-card-description,
6379
+ .catalog-page .product-card-sku {
6380
+ display: none;
6381
+ }
6382
+ .catalog-page .product-card-price {
6383
+ margin-top: auto;
6384
+ }
6385
+ .catalog-page .product-card-price strong {
6386
+ font-size: 16px;
6387
+ }
6388
+ .catalog-page .product-card-price > span {
6389
+ font-size: 11px;
6390
+ }
6391
+ .catalog-page .product-card-content > .product-card-action {
6392
+ min-height: 40px;
6393
+ margin-top: 4px !important;
6394
+ padding: 8px 5px;
6395
+ font-size: 11px;
6396
+ line-height: 1.3;
6397
+ text-align: center;
6398
+ }
6399
+ .catalog-page .product-card-badge,
6400
+ .catalog-page .product-card-stock {
6401
+ padding: 4px 6px;
6402
+ font-size: 9px;
6403
+ }
6404
+ .catalog-page .catalog-pagination {
6405
+ flex-wrap: wrap;
6406
+ gap: 10px;
6407
+ }
6408
+ .catalog-page .catalog-pagination > a {
6409
+ min-height: 44px;
6410
+ }
6411
+ }
6412
+
6413
+ .mobile-menu-trigger {
6414
+ color: var(--mobile-menu-text, var(--store-header-text));
6415
+ }
6416
+ .mobile-menu-trigger:hover {
6417
+ background: var(--mobile-menu-hover, transparent);
6418
+ }
6419
+ .mobile-menu-trigger:focus-visible {
6420
+ outline: 2px solid currentColor;
6421
+ outline-offset: 2px;
6422
+ }
@@ -0,0 +1,82 @@
1
+ import type { ThemeCartItem } from "@nuvler/theme-sdk";
2
+
3
+ export const whatsappRequestLabel = "Enviar solicitação pelo WhatsApp";
4
+ const introduction =
5
+ "Olá! Gostaria de solicitar os itens abaixo. Podem confirmar os valores e a disponibilidade?";
6
+ const money = (value: number) =>
7
+ new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(
8
+ value,
9
+ );
10
+
11
+ type RequestItem = ThemeCartItem & { quantity?: number };
12
+
13
+ function absoluteProductUrl(
14
+ value: string | undefined,
15
+ storeOrigin?: string,
16
+ ): string | null {
17
+ if (!value) return null;
18
+ try {
19
+ const url = storeOrigin ? new URL(value, storeOrigin) : new URL(value);
20
+ return url.protocol === "https:" || url.protocol === "http:"
21
+ ? url.href
22
+ : null;
23
+ } catch {
24
+ return null;
25
+ }
26
+ }
27
+
28
+ /** Encode the complete message once, preserving its paragraph breaks. */
29
+ export function whatsappRequestUrl(phone: string, message: string): string {
30
+ return `https://wa.me/${phone.replace(/\D/g, "")}?text=${encodeURIComponent(message)}`;
31
+ }
32
+
33
+ /** Formats a quote/request without imposing an order or quotation workflow. */
34
+ export function formatWhatsappRequest(
35
+ items: RequestItem[],
36
+ showPrices = true,
37
+ storeOrigin?: string,
38
+ ): string {
39
+ const products = items.map((item, index) => {
40
+ const quantity = item.quantity ?? 1;
41
+ const lines = [`*${index + 1}. ${item.title}*`, `Quantidade: ${quantity}`];
42
+ if (item.variantName) lines.push(item.variantName);
43
+ if (item.sku) lines.push(`Referência: ${item.sku}`);
44
+ if (showPrices && typeof item.unitPrice === "number") {
45
+ lines.push(`Valor unitário: ${money(item.unitPrice)}`);
46
+ if (quantity > 1)
47
+ lines.push(`Subtotal: ${money(item.unitPrice * quantity)}`);
48
+ }
49
+ if (item.kitGroups?.length) {
50
+ for (const group of item.kitGroups) {
51
+ lines.push(
52
+ `*${group.name} — ${group.quantity} ${group.quantity === 1 ? "unidade" : "unidades"} por combo*`,
53
+ );
54
+ lines.push(
55
+ ...(item.composition ?? [])
56
+ .filter((part) => part.groupId === group.id)
57
+ .map((part) => `• ${part.name}: ${part.quantity}`),
58
+ );
59
+ }
60
+ } else if (item.composition?.length) {
61
+ lines.push(
62
+ ...(item.composition ?? []).map(
63
+ (part) => `• ${part.name}: ${part.quantity}`,
64
+ ),
65
+ );
66
+ }
67
+ const productUrl = absoluteProductUrl(item.productUrl, storeOrigin);
68
+ if (productUrl) lines.push(productUrl);
69
+ return lines.join("\n\n");
70
+ });
71
+ const sections = [introduction, ...products];
72
+ if (
73
+ showPrices &&
74
+ items.length > 0 &&
75
+ items.every((item) => typeof item.unitPrice === "number")
76
+ ) {
77
+ sections.push(
78
+ `*Total estimado: ${money(items.reduce((total, item) => total + item.unitPrice! * (item.quantity ?? 1), 0))}*`,
79
+ );
80
+ }
81
+ return sections.join("\n\n");
82
+ }
@@ -0,0 +1,44 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { createElement } from "react";
4
+ import { renderToStaticMarkup } from "react-dom/server";
5
+ import { CatalogFilters } from "../dist/src/catalog-filters.js";
6
+
7
+ function render(activeCount = 0) {
8
+ return renderToStaticMarkup(
9
+ createElement(
10
+ CatalogFilters,
11
+ { total: 30, activeCount, resetHref: "/produtos" },
12
+ createElement(
13
+ "form",
14
+ { className: "catalog-filter-form", action: "/produtos" },
15
+ createElement("input", {
16
+ id: "test-search",
17
+ type: "search",
18
+ name: "busca",
19
+ defaultValue: "Coxinha",
20
+ }),
21
+ ),
22
+ ),
23
+ );
24
+ }
25
+ test("mobile filters start closed and keep a single set of inputs for desktop and mobile", () => {
26
+ const html = render();
27
+ assert.match(html, /aria-expanded="false"/);
28
+ assert.doesNotMatch(
29
+ html,
30
+ /aria-modal="true"|role="dialog"|class="catalog-filter-backdrop"/,
31
+ );
32
+ assert.equal((html.match(/id="test-search"/g) ?? []).length, 1);
33
+ assert.match(html, /value="Coxinha"/);
34
+ assert.match(html, /30 produtos/);
35
+ assert.match(html, /Ver resultados/);
36
+ assert.match(html, /href="\/produtos">Limpar/);
37
+ });
38
+ test("filter controls expose the active count and point to the matching panel", () => {
39
+ const html = render(3);
40
+ assert.match(html, /class="catalog-filter-count">3/);
41
+ const controls = html.match(/aria-controls="([^"]+)"/)[1];
42
+ assert.ok(html.includes(`id="${controls}"`));
43
+ assert.match(html, /aria-label="Fechar filtros"/);
44
+ });
@@ -0,0 +1,74 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { interactionColorVariables } from "../dist/src/interaction-colors.js";
4
+ import { ThemeSiteColorsSchema } from "../../../packages/theme-schema/dist/index.js";
5
+ const base = {
6
+ primary: "#176b3a",
7
+ secondary: "#d99b31",
8
+ background: "#f7f7f2",
9
+ text: "#18221b",
10
+ surface: "#ffffff",
11
+ surfaceAlt: "#f4f7f3",
12
+ textMuted: "#657068",
13
+ border: "#dce3dc",
14
+ };
15
+ test("existing stores retain their search and cart colors", () => {
16
+ const css = interactionColorVariables(base);
17
+ assert.equal(css["--search-background"], base.surface);
18
+ assert.equal(css["--cart-background"], base.surface);
19
+ assert.equal(css["--cart-text"], base.text);
20
+ assert.equal(css["--cart-close-background"], base.background);
21
+ });
22
+ test("component colors remain independent and survive preview validation", () => {
23
+ const colors = ThemeSiteColorsSchema.parse({
24
+ ...base,
25
+ searchBackground: "#000000",
26
+ searchText: "#ffffff",
27
+ searchButtonBackground: "#123456",
28
+ searchButtonText: "#abcdef",
29
+ cartButtonBackground: "#010101",
30
+ cartButtonText: "#fefefe",
31
+ cartBackground: "#222222",
32
+ cartText: "#eeeeee",
33
+ });
34
+ const css = interactionColorVariables(colors);
35
+ assert.equal(css["--search-background"], "#000000");
36
+ assert.equal(css["--cart-background"], "#222222");
37
+ assert.equal(css["--cart-button-background"], "#010101");
38
+ assert.equal(css["--search-button-text"], "#abcdef");
39
+ assert.ok(css["--cart-muted"].includes("#eeeeee"));
40
+ assert.equal(base.surface, "#ffffff");
41
+ });
42
+
43
+ test("collapsed search uses configured button colors and follows header text by default", () => {
44
+ const defaults = interactionColorVariables({
45
+ ...base,
46
+ headerBackground: "#000000",
47
+ headerText: "#ffffff",
48
+ });
49
+ assert.equal(defaults["--search-toggle-background"], "transparent");
50
+ assert.equal(defaults["--search-toggle-text"], "#ffffff");
51
+ const configured = interactionColorVariables({
52
+ ...base,
53
+ searchButtonBackground: "#e2ae40",
54
+ searchButtonText: "#00aaff",
55
+ });
56
+ assert.equal(configured["--search-toggle-background"], "#e2ae40");
57
+ assert.equal(configured["--search-toggle-text"], "#00aaff");
58
+ assert.ok(configured["--search-toggle-hover"].includes("#e2ae40"));
59
+ });
60
+
61
+ test("mobile menu follows header text unless explicitly customized", () => {
62
+ const defaults = interactionColorVariables({ ...base, headerText: "#ffffff" });
63
+ assert.equal(defaults["--mobile-menu-text"], "#ffffff");
64
+ const colors = ThemeSiteColorsSchema.parse({
65
+ ...base,
66
+ headerText: "#ffffff",
67
+ mobileMenuText: "#00aaff",
68
+ });
69
+ const customized = interactionColorVariables(colors);
70
+ assert.equal(customized["--mobile-menu-text"], "#00aaff");
71
+ assert.ok(customized["--mobile-menu-hover"].includes("#00aaff"));
72
+ assert.equal(customized["--cart-button-text"], base.text);
73
+ assert.equal(ThemeSiteColorsSchema.safeParse({ ...base, mobileMenuText: "blue" }).success, false);
74
+ });
@@ -0,0 +1,28 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { kitCompositionText } from "../dist/src/kit-composition.js";
4
+
5
+ test("default theme shows kit choices without the generated prefix", () => {
6
+ assert.equal(
7
+ kitCompositionText({
8
+ kitSize: 100,
9
+ composition: [
10
+ { variantId: "a", name: "Coxinha", quantity: 40 },
11
+ { variantId: "b", name: "Quibe", quantity: 60 },
12
+ ],
13
+ }),
14
+ "Coxinha: 40; Quibe: 60",
15
+ );
16
+ assert.equal(kitCompositionText({ kitSize: 100 }), "");
17
+ assert.equal(kitCompositionText({}), "");
18
+ });
19
+
20
+ test("independent groups retain their names and separate quantities", () => {
21
+ const result = kitCompositionText({
22
+ kitGroups: [{ id: "drinks", name: "Bebidas", quantity: 2, options: [] }],
23
+ composition: [
24
+ { groupId: "drinks", variantId: "a", name: "Suco", quantity: 2 },
25
+ ],
26
+ });
27
+ assert.equal(result, "Bebidas (2 un. por combo): Suco: 2");
28
+ });
@@ -53,13 +53,13 @@ test("kit starts empty, displays its configured size, blocks checkout and inacti
53
53
  assert.match(html, /Selecionados: 0 de 50 · Faltam: 50/);
54
54
  assert.match(html, /Indisponível/);
55
55
  assert.match(html, /id="kit-b"[^>]*disabled=""/);
56
- assert.match(html, /<button disabled=""[^>]*>Adicionar ao orçamento/);
56
+ assert.match(html, /<button disabled=""[^>]*>Adicionar ao Carrinho/);
57
57
  });
58
58
  test("ordinary variants keep the single selection interface", () => {
59
59
  const html = render({ ...product, kitSize: null });
60
60
  assert.doesNotMatch(html, /kit-selector/);
61
61
  assert.match(html, /variant-selector/);
62
- assert.doesNotMatch(html, /<button disabled=""[^>]*>Adicionar ao orçamento/);
62
+ assert.doesNotMatch(html, /<button disabled=""[^>]*>Adicionar ao Carrinho/);
63
63
  });
64
64
 
65
65
  test("a combo shows three independently counted groups instead of crossed variants", () => {
@@ -81,7 +81,7 @@ test("a combo shows three independently counted groups instead of crossed varian
81
81
  );
82
82
  }
83
83
  assert.doesNotMatch(html, /variant-selector/);
84
- assert.match(html, /<button disabled=""[^>]*>Adicionar ao orçamento/);
84
+ assert.match(html, /<button disabled=""[^>]*>Adicionar ao Carrinho/);
85
85
  });
86
86
 
87
87
  import { KitGroupSelector } from "../dist/src/kit-group-selector.js";