@garagem-ai/site-sdk 0.5.2 → 0.5.3
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 +16 -25
- package/dist/index.d.mts +202 -28
- package/dist/index.d.ts +202 -28
- package/dist/index.js +41 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -42
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +2 -60
- package/dist/react.d.ts +2 -60
- package/dist/react.js +150 -862
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +122 -820
- package/dist/react.mjs.map +1 -1
- package/dist/{search-engine-4ocM0UPk.d.mts → search-engine-CkbO77G8.d.mts} +11 -181
- package/dist/{search-engine-4ocM0UPk.d.ts → search-engine-CkbO77G8.d.ts} +11 -181
- package/package.json +4 -9
- package/src/amenity-labels.ts +9 -2
- package/src/fetchers.ts +2 -1
- package/src/index.ts +1 -2
- package/src/internal/url.ts +1 -0
- package/src/listing-detail.ts +2 -1
- package/src/presentation.ts +1 -24
- package/src/react/index.ts +0 -11
- package/src/react/staged-filters-mirror.ts +38 -0
- package/src/react/types.ts +0 -30
- package/src/react/use-public-search.ts +30 -10
- package/src/search-engine.ts +3 -0
- package/src/studio-contract.ts +35 -20
- package/src/types.ts +10 -0
- package/src/react/cn.ts +0 -3
- package/src/react/listing-card.tsx +0 -98
- package/src/react/listing-detail-fields.tsx +0 -119
- package/src/react/search-chrome.tsx +0 -29
- package/src/react/search.css +0 -214
- package/src/react/styles/index.ts +0 -1
- package/src/react/styles/search-chrome-css.generated.ts +0 -5
- package/src/react/styles/search-chrome-styles.tsx +0 -31
package/src/react/types.ts
CHANGED
|
@@ -1,41 +1,11 @@
|
|
|
1
|
-
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
-
|
|
3
1
|
import type {
|
|
4
2
|
AppliedSearchQuery,
|
|
5
3
|
Listing,
|
|
6
4
|
SearchPathFilters,
|
|
7
5
|
SearchUi,
|
|
8
6
|
} from "../types";
|
|
9
|
-
import type { ListingCardModel } from "../listing-card-model";
|
|
10
7
|
import type { LocationNameTables } from "../search-engine";
|
|
11
8
|
|
|
12
|
-
export type ListingCardClassNames = {
|
|
13
|
-
root?: string;
|
|
14
|
-
media?: string;
|
|
15
|
-
badge?: string;
|
|
16
|
-
body?: string;
|
|
17
|
-
price?: string;
|
|
18
|
-
title?: string;
|
|
19
|
-
location?: string;
|
|
20
|
-
features?: string;
|
|
21
|
-
cta?: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type ListingCardSlots = {
|
|
25
|
-
media?: ReactNode;
|
|
26
|
-
badge?: ReactNode;
|
|
27
|
-
cta?: ReactNode;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export type ListingCardProps = {
|
|
31
|
-
listing: Listing | ListingCardModel;
|
|
32
|
-
href?: string;
|
|
33
|
-
className?: string;
|
|
34
|
-
classNames?: ListingCardClassNames;
|
|
35
|
-
slots?: ListingCardSlots;
|
|
36
|
-
style?: CSSProperties;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
9
|
export type SiteIdInput =
|
|
40
10
|
| string
|
|
41
11
|
| Promise<string>
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
applyPathFilter,
|
|
10
10
|
buildQueryListingsParams,
|
|
11
11
|
canonicalizeSearchHref,
|
|
12
|
-
clearStagedPathFilters,
|
|
13
12
|
hrefForAppliedChange,
|
|
14
13
|
hrefForPathFilters,
|
|
15
14
|
readPublicSearch,
|
|
@@ -21,6 +20,7 @@ import type {
|
|
|
21
20
|
SiteIdInput,
|
|
22
21
|
UsePublicSearchOptions,
|
|
23
22
|
} from "./types";
|
|
23
|
+
import { StagedFiltersMirror } from "./staged-filters-mirror";
|
|
24
24
|
|
|
25
25
|
async function resolveSiteIdInput(siteId: SiteIdInput): Promise<string> {
|
|
26
26
|
const value = typeof siteId === "function" ? siteId() : siteId;
|
|
@@ -52,11 +52,17 @@ export function usePublicSearch(
|
|
|
52
52
|
const [totalPages, setTotalPages] = useState(1);
|
|
53
53
|
const [loading, setLoading] = useState(true);
|
|
54
54
|
const [qDraft, setQDraft] = useState("");
|
|
55
|
-
const
|
|
55
|
+
const stagedMirrorRef = useRef(new StagedFiltersMirror());
|
|
56
|
+
const [staged, setStagedState] = useState<SearchPathFilters>({});
|
|
56
57
|
const [locationNames, setLocationNames] = useState<LocationNameTables | null>(
|
|
57
58
|
null
|
|
58
59
|
);
|
|
59
60
|
|
|
61
|
+
const replaceStaged = useCallback((next: SearchPathFilters) => {
|
|
62
|
+
stagedMirrorRef.current.replace(next);
|
|
63
|
+
setStagedState(next);
|
|
64
|
+
}, []);
|
|
65
|
+
|
|
60
66
|
const parsed = useMemo(
|
|
61
67
|
() => readPublicSearch(pathname, search, schema?.dictionary),
|
|
62
68
|
[pathname, search, schema?.dictionary]
|
|
@@ -67,12 +73,12 @@ export function usePublicSearch(
|
|
|
67
73
|
}, [parsed.applied.query]);
|
|
68
74
|
|
|
69
75
|
const resetStagedFromUrl = useCallback(() => {
|
|
70
|
-
|
|
71
|
-
}, [parsed.pathFilters]);
|
|
76
|
+
replaceStaged({ ...parsed.pathFilters });
|
|
77
|
+
}, [parsed.pathFilters, replaceStaged]);
|
|
72
78
|
|
|
73
79
|
useEffect(() => {
|
|
74
|
-
|
|
75
|
-
}, [parsed.pathFilters]);
|
|
80
|
+
replaceStaged({ ...parsed.pathFilters });
|
|
81
|
+
}, [parsed.pathFilters, replaceStaged]);
|
|
76
82
|
|
|
77
83
|
const locationsRef = useRef<LocationNameTables | null>(null);
|
|
78
84
|
|
|
@@ -216,17 +222,31 @@ export function usePublicSearch(
|
|
|
216
222
|
[go, pathname, search, schema, parsed.pathFilters]
|
|
217
223
|
);
|
|
218
224
|
|
|
225
|
+
const setStaged = useCallback(
|
|
226
|
+
(next: SearchPathFilters) => {
|
|
227
|
+
replaceStaged(next);
|
|
228
|
+
},
|
|
229
|
+
[replaceStaged]
|
|
230
|
+
);
|
|
231
|
+
|
|
219
232
|
const stageFilter = useCallback((filterId: string, value: unknown) => {
|
|
220
|
-
|
|
233
|
+
setStagedState(stagedMirrorRef.current.stage(filterId, value));
|
|
221
234
|
}, []);
|
|
222
235
|
|
|
223
236
|
const applyStaged = useCallback(() => {
|
|
224
237
|
if (!schema) return;
|
|
225
|
-
go(
|
|
226
|
-
|
|
238
|
+
go(
|
|
239
|
+
hrefForPathFilters(
|
|
240
|
+
pathname,
|
|
241
|
+
search,
|
|
242
|
+
schema.dictionary,
|
|
243
|
+
stagedMirrorRef.current.value
|
|
244
|
+
)
|
|
245
|
+
);
|
|
246
|
+
}, [go, pathname, search, schema]);
|
|
227
247
|
|
|
228
248
|
const clearStaged = useCallback(() => {
|
|
229
|
-
|
|
249
|
+
setStagedState(stagedMirrorRef.current.clear());
|
|
230
250
|
}, []);
|
|
231
251
|
|
|
232
252
|
const submitQuery = useCallback(() => {
|
package/src/search-engine.ts
CHANGED
|
@@ -305,6 +305,9 @@ export function canonicalizeSearchHref(
|
|
|
305
305
|
search: string,
|
|
306
306
|
dictionary?: SearchUiDictionary
|
|
307
307
|
): string | null {
|
|
308
|
+
// A preview prefix is not a filter. Replacing it rewrites the URL forever.
|
|
309
|
+
if (pathname.includes("/api/v0-preview/")) return null;
|
|
310
|
+
if (isListingDetailPath(pathname)) return null;
|
|
308
311
|
const { pathFilters, applied } = readPublicSearch(
|
|
309
312
|
pathname,
|
|
310
313
|
search,
|
package/src/studio-contract.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* object — do not keep a second list of required `@garagem-ai/site-sdk/react`
|
|
4
4
|
* names in apps/site.
|
|
5
5
|
*
|
|
6
|
-
* `minNpmVersion` is the tarball v0 actually installs.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* `minNpmVersion` is the tarball v0 actually installs. Retired / optional
|
|
7
|
+
* `/react` chrome may still exist on that tarball; Studio codegen must not
|
|
8
|
+
* name those identifiers (v0 copies them). Card and search chrome markup
|
|
9
|
+
* are app-owned (`chromeStrategy: app-owned`).
|
|
10
10
|
*/
|
|
11
11
|
import { SEARCH_EMPTY_COPY } from "./search-engine";
|
|
12
12
|
|
|
@@ -23,25 +23,23 @@ export const STUDIO_SDK_CONTRACT = {
|
|
|
23
23
|
* 0.4.12 (`visibleSearchFilters` / `toolbarFilterIds` are on that pin).
|
|
24
24
|
*/
|
|
25
25
|
minNpmVersion: "0.4.12",
|
|
26
|
-
/**
|
|
26
|
+
/** Historical: older tarballs inject card CSS when those components mount. */
|
|
27
27
|
selfInjectSince: "0.4.2",
|
|
28
|
-
chromeStrategy: "
|
|
29
|
-
reactExports: ["usePublicSearch"
|
|
28
|
+
chromeStrategy: "app-owned" as const,
|
|
29
|
+
reactExports: ["usePublicSearch"] as const,
|
|
30
30
|
/**
|
|
31
|
-
* Names that exist in git /
|
|
31
|
+
* Names that exist in git / unpublished patches. Completeness treats an
|
|
32
32
|
* import as `sdk-export-mismatch` when the generated pin is older than
|
|
33
33
|
* `since`. Studio prompts must not mention these names at all (even as
|
|
34
34
|
* “never import”) — v0 copies the identifier and the preview ESM loader
|
|
35
35
|
* throws FatalRendererError.
|
|
36
36
|
*/
|
|
37
|
-
optionalReactExports: {
|
|
38
|
-
SearchChromeStyles: "0.4.1",
|
|
39
|
-
ListingDetailFields: "0.4.13",
|
|
40
|
-
} as const,
|
|
37
|
+
optionalReactExports: {} as Record<string, string>,
|
|
41
38
|
/**
|
|
42
|
-
* Former `/react` chrome
|
|
43
|
-
* `reactExports`). Prompts must not
|
|
44
|
-
* identifiers even inside
|
|
39
|
+
* Former `/react` chrome (including card/skeleton inject). Completeness
|
|
40
|
+
* flags imports as mismatch (not in `reactExports`). Prompts must not
|
|
41
|
+
* mention these names at all — v0 copies identifiers even inside
|
|
42
|
+
* “never import”.
|
|
45
43
|
*/
|
|
46
44
|
retiredReactExports: [
|
|
47
45
|
"SearchPage",
|
|
@@ -50,6 +48,10 @@ export const STUDIO_SDK_CONTRACT = {
|
|
|
50
48
|
"FilterPanel",
|
|
51
49
|
"SearchPagination",
|
|
52
50
|
"SearchPageFallback",
|
|
51
|
+
"ListingCard",
|
|
52
|
+
"ResultsSkeleton",
|
|
53
|
+
"SearchChromeStyles",
|
|
54
|
+
"ListingDetailFields",
|
|
53
55
|
] as const,
|
|
54
56
|
forbiddenImports: ["@garagem-ai/site-sdk/react/search.css"] as const,
|
|
55
57
|
leadStrategy: "visit-default" as const,
|
|
@@ -64,6 +66,14 @@ export const STUDIO_SDK_CONTRACT = {
|
|
|
64
66
|
"STUDIO_DEFAULT_VISIT_SCHEDULE",
|
|
65
67
|
] as const,
|
|
66
68
|
listingDetailExports: ["listingDetailModel", "getSimilarListings"] as const,
|
|
69
|
+
/** Main-package card helpers — markup stays in the generated app. */
|
|
70
|
+
listingCardExports: [
|
|
71
|
+
"toListingCardModel",
|
|
72
|
+
"listingPublicPath",
|
|
73
|
+
"formatAreaM2",
|
|
74
|
+
"listingBusinessLabel",
|
|
75
|
+
"formatListingPrice",
|
|
76
|
+
] as const,
|
|
67
77
|
amenityExports: ["listingAmenityGroups"] as const,
|
|
68
78
|
/**
|
|
69
79
|
* Names already on the pinned npm tarball (`minNpmVersion` / 0.4.12) —
|
|
@@ -129,7 +139,7 @@ Every page section is two layers: (1) surface — \`section\` / header / footer
|
|
|
129
139
|
}
|
|
130
140
|
|
|
131
141
|
export function studioSearchLandmarkInstruction(): string {
|
|
132
|
-
return `Search at \`/imoveis\` (hard rule). The page landmark is \`<main className="${STUDIO_SITE_LAYOUT.searchMainClassName}">\` with one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`. Wire the catalog with \`usePublicSearch\` from \`${STUDIO_SDK_PACKAGE}/react\` inside \`<Suspense fallback
|
|
142
|
+
return `Search at \`/imoveis\` (hard rule). The page landmark is \`<main className="${STUDIO_SITE_LAYOUT.searchMainClassName}">\` with one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`. Wire the catalog with \`usePublicSearch\` from \`${STUDIO_SDK_PACKAGE}/react\` inside \`<Suspense>\` whose fallback is the site listing-card-skeleton module. Do not wrap the search UI in \`<section>\` or a second max-width. The page owns the SEO heading as \`<div data-slot="search-heading">\`: count \`<span data-slot="search-heading-count">\` FIRST, then \`<h1 data-slot="search-heading-title">\` — never put the count inside the H1 and never put the h1 first. \`pt-4 pb-12\` is the default on that search \`<main>\` — change those values if the design needs it. Flush search (glued to the header) is allowed only with \`${STUDIO_SITE_LAYOUT.searchFlushMarker}\` on that \`<main>\`. Never add that vertical padding to home heroes or listing galleries.`;
|
|
133
143
|
}
|
|
134
144
|
|
|
135
145
|
const REACT_SDK_NAMED_IMPORT_RE =
|
|
@@ -208,23 +218,28 @@ export function studioLeadInstruction(): string {
|
|
|
208
218
|
return `Listing-detail visit/contact leads: import ${names} from \`${STUDIO_SDK_PACKAGE}\` (the main package, not \`/react\`). Call \`submitVisitLead\` / \`submitContactLead\` — never concatenate a leads webhook URL and never POST the Showcase demo leads route.`;
|
|
209
219
|
}
|
|
210
220
|
|
|
221
|
+
export function studioListingCardInstruction(): string {
|
|
222
|
+
const names = STUDIO_SDK_CONTRACT.listingCardExports.join(", ");
|
|
223
|
+
return `Listing card (site-wide). WRITE \`components/garagem/listing-card.tsx\` — one module for home, search results, and similar listings. Do not invent a second card. From \`${STUDIO_SDK_PACKAGE}\` import ${names}. \`const model = toListingCardModel(listing)\`. href is \`model.href\` / \`listingPublicPath(listing)\` — never \`listing.id\` or \`property.id\`. Skip the card or omit the link when href is empty (no \`href=""\`, no \`href="#"\`). Must show title (\`model.title\`) and price (\`model.priceLabel\` — “Sob consulta” when private; \`model.pricePeriod\` “/mês” when present, omit when null). Photo: \`model.coverSrc\` as img \`src\`, alt \`model.coverAlt\`; skip the img when cover is missing; an empty-photo block is allowed; never Unsplash, \`/placeholder.svg\`, or invented \`?query=\` images. Show when present, omit the line when missing: \`locationLabel\` (else \`propertyType\`), \`listingBusinessLabel\` / \`model.businessLabel\`, bedrooms, bathrooms, parkingSpaces, area via \`formatAreaM2\`. Never interpolate the listing object as a React child. Design is free (grid vs carousel vs mosaic; radius is site \`--radius\`). WRITE \`components/garagem/listing-card-skeleton.tsx\` for the search \`<Suspense>\` fallback — it should suggest the card surface, never the text “Carregando imóveis…”. Do not \`if (search.loading) return\` that skeleton inside the search client.`;
|
|
224
|
+
}
|
|
225
|
+
|
|
211
226
|
export function studioListingDetailInstruction(): string {
|
|
212
227
|
const names = STUDIO_SDK_CONTRACT.listingDetailExports.join(", ");
|
|
213
|
-
return `Listing detail: import ${names} from \`${STUDIO_SDK_PACKAGE}
|
|
228
|
+
return `Listing detail: import ${names} from \`${STUDIO_SDK_PACKAGE}\`. Render \`listingDetailModel\` leaves: \`model.facts[].label\` / \`.text\`, \`model.values[].label\` / \`.text\`, \`model.location.label\` / \`model.location.mapsHref\`, breadcrumb \`.href\` (search prefixes of \`listing.path\`). The preço / sob consulta entry is the primary value; condomínio and IPTU are secondary and omitted when missing. \`model.description\` is the complete string — do not slice. A collapsed disclosure uses a container (max-height or overflow), not a cut of the string. Never interpolate \`model.location\`, \`model.facts\`, \`model.values\`, \`model.breadcrumb\`, or \`model.mediaOverlays\` as a React child. Video/tour: \`model.mediaOverlays\` as hash links (\`#video\` / \`#tour\`); player src is \`embedSrc\`; fullscreen overlay closes with browser back; omit when that overlay is absent. Do not key the page on \`location.hash\`. Similar listings: \`getSimilarListings({ siteId, listingId, baseUrl })\` plus the site listing-card module; hide the section when empty. Do not invent a local recommendation loop.`;
|
|
214
229
|
}
|
|
215
230
|
|
|
216
231
|
export function studioAmenityInstruction(): string {
|
|
217
|
-
return `Listing amenities: Portuguese labels from \`listingAmenityGroups(listing)\` (
|
|
232
|
+
return `Listing amenities: Portuguese labels from \`listingAmenityGroups(listing, dictionary)\` (pass the dictionary from \`getSearchUi()\` so section titles follow Campos). Each group is \`{ title, labels: string[] }\` — render \`group.title\` and \`group.labels.map((label) => …)\` and hide a group when \`group.labels.length === 0\`. Do not hardcode section titles. Never print amenity ids, never invent a local label map, and never title a section "Comodidades da unidade".`;
|
|
218
233
|
}
|
|
219
234
|
|
|
220
235
|
export function studioSearchInstruction(): string {
|
|
221
236
|
const reactNames = STUDIO_SDK_CONTRACT.reactExports.join(", ");
|
|
222
237
|
const libNames = STUDIO_SDK_CONTRACT.searchExports.join(", ");
|
|
223
|
-
return `Search: import ${reactNames} from \`${STUDIO_SDK_PACKAGE}/react\`. From \`${STUDIO_SDK_PACKAGE}\` import ${libNames}. Call \`const search = usePublicSearch({ siteId, baseUrl: GARAGEM_API_BASE })\` in a client component inside \`<Suspense>\` (\`useSearchParams\`). Compose the page UI in the app — do not paste a canonical search TSX. Required chrome (design is free; omit none): query (\`qDraft\` / \`setQDraft\` / form \`preventDefault\` + \`submitQuery\`), heading (count span FIRST then h1 from \`searchResultsHeading(search.pathFilters, search.schema?.dictionary, search.locationNames)\` — never \`searchResultsHeading({})\`), toolbar (\`toolbarFilterIds\` + \`applyFilter\`; range “Atualizar” on that toolbar item only) vs sheet (\`visibleSearchFilters\` extras, \`stageFilter\`, one footer \`applyStaged\`), sort (\`searchSortOptions\` + \`setSort\`; first option id is \`""\` — map to Select sentinel \`"relevancia"
|
|
238
|
+
return `Search: import ${reactNames} from \`${STUDIO_SDK_PACKAGE}/react\`. From \`${STUDIO_SDK_PACKAGE}\` import ${libNames}. Call \`const search = usePublicSearch({ siteId, baseUrl: GARAGEM_API_BASE })\` in a client component inside \`<Suspense>\` (\`useSearchParams\`). Compose the page UI in the app — do not paste a canonical search TSX. Required chrome (design is free; omit none): query (\`qDraft\` / \`setQDraft\` / form \`preventDefault\` + \`submitQuery\`), heading (count span FIRST then h1 from \`searchResultsHeading(search.pathFilters, search.schema?.dictionary, search.locationNames)\` — never \`searchResultsHeading({})\`), toolbar (\`toolbarFilterIds\` + \`applyFilter\`; range “Atualizar” on that toolbar item only) vs sheet (\`visibleSearchFilters\` extras, \`stageFilter\`, one footer \`applyStaged\`), sort (\`searchSortOptions\` + \`setSort\`; first option id is \`""\` / “Mais relevantes” — map **only** that empty id to Select sentinel \`"relevancia"\` (\`opt.id || "relevancia"\`), never \`SelectItem value=""\` and never give “Mais recentes” (\`id: "recentes"\`, \`?ordenar=recentes\`) that sentinel; on change \`setSort(id === "relevancia" ? "" : id)\` so recentes stays recentes. Closed trigger shows the option \`.label\`, never \`{search.applied.sort}\`), grid (\`listings.map\` + the site listing-card module; listing-card-skeleton is only the Suspense fallback; do not \`throw\` in that chrome), pagination (\`paginationPages\` + \`hrefWithExplicitPage\`). Never interpolate \`schema\`, \`pathFilters\`, or a filter object as a React child. \`queryListings\` key is \`params\`. The URL is the document. Count text is \`{search.total}\` only. Heading is one row; font size lives on the container and the span and h1 use \`font-size: inherit\`. Sort trigger shows the option label (“Mais relevantes” when \`ordenar\` is absent), chevron at the end, same height as the toolbar controls. Toolbar ranges open a Popover form (not DropdownMenu — Menu typeahead swallows digit keys) whose submit calls \`applyFilter\`; the popup clips and the two inputs stay inside (\`min-w-0\`, no \`w-64\`). Reset min/max drafts when the popover opens and when the applied path range changes. The sheet omits toolbar ids (price, bedrooms) so Preço is never a heading without inputs. Sheet DialogContent uses \`h-[min(640px,85dvh)]\` (not max-h alone) so the body ScrollArea can move. Tipo de imóvel, características and comodidades each use a nested ScrollArea with \`h-56 overflow-hidden\` (viewport \`h-full\`). Area is two inputs in schema order with no “Aplicar”; the footer stages then applyStaged. Never read \`staged[filter.id]\` — path keys are \`bedrooms\` / \`listingType\` / \`bathrooms\`. Bedrooms Select reads \`pathFilters.bedrooms\` so \`/imoveis/4-quartos\` checks \`"4"\` and shows the same trigger dot as price. Bathrooms and parking pressed state uses \`pathFilterHasOption\`. Limpar keeps location plus toolbar price and bedrooms via \`clearStagedPathFilters\` and \`toolbarFilterIds\`; do not call \`clearStaged\` for that button. It enables only when staged has a path filter other than location and those kept toolbar ids. Each multi-select \`stageFilter\` value is one option id, never a concatenated slug; \`checked\` uses \`pathFilterHasOption\`. Listing type does not pass the clicked id: no path value shows every checkbox checked, unchecking one stages the other option's id, and the last box stays checked. Price inputs use formatGroupedInteger. The closed price and bedrooms triggers keep the filter label plus a dot when set — never the literal range. Empty price calls applyFilter(id, undefined); never send 0 or 1000000000. Area is a plain integer (not that mask). The results button stageFilter property_area_total with both drafts, then applyStaged. Never send 0 or 100000. Count buttons pass the option id (\`"2"\`), never the label \`"2+"\`. Property type, features, and amenities render in pt-BR label order. Do not set \`[data-slot="search-sort"] { flex-direction: column }\` in a \`<style>\` tag; that selector is row so the chevron sits beside the label. Empty copy: ${JSON.stringify(SEARCH_EMPTY_COPY)}`;
|
|
224
239
|
}
|
|
225
240
|
|
|
226
241
|
export function studioChromeInstruction(): string {
|
|
227
|
-
return `
|
|
242
|
+
return `Card, skeleton, and search chrome markup are app-owned. Never \`import "${STUDIO_SDK_CONTRACT.forbiddenImports[0]}"\` — v0 preview cannot load npm CSS. Do not mount an SDK stylesheet. Theme with site tokens and \`--radius\` in \`app/globals.css\`.`;
|
|
228
243
|
}
|
|
229
244
|
|
|
230
245
|
function mentionsExportName(text: string, name: string): boolean {
|
package/src/types.ts
CHANGED
|
@@ -102,6 +102,11 @@ export interface Listing {
|
|
|
102
102
|
* details and richer property info. Returned by `getListing`.
|
|
103
103
|
*/
|
|
104
104
|
export interface ListingDetail extends Listing {
|
|
105
|
+
/**
|
|
106
|
+
* Precomputed IPTU period label from tenant Campos (e.g. `IPTU/ano`,
|
|
107
|
+
* `IPTU/mês (10x)`). Render as-is; do not derive from raw period fields.
|
|
108
|
+
*/
|
|
109
|
+
propertyTaxLabel?: string;
|
|
105
110
|
/**
|
|
106
111
|
* Unit + building amenity ids (legacy merged list). Prefer
|
|
107
112
|
* `propertyFeatures` and `buildingAmenities` with `listingAmenityGroups`.
|
|
@@ -176,6 +181,11 @@ export type SearchUiDictionary = {
|
|
|
176
181
|
propertyTypes: SearchUiOption[];
|
|
177
182
|
propertyFeatures: SearchUiOption[];
|
|
178
183
|
buildingAmenities: SearchUiOption[];
|
|
184
|
+
/** Present only when Campos amenity display is flat (checkbox / alphabetical). */
|
|
185
|
+
amenitySectionTitles?: {
|
|
186
|
+
unit?: string;
|
|
187
|
+
building?: string;
|
|
188
|
+
};
|
|
179
189
|
};
|
|
180
190
|
|
|
181
191
|
/** Geo leftovers on a default-V2 search path (`/imoveis/...`). */
|
package/src/react/cn.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import type { ReactElement } from "react";
|
|
4
|
-
import Link from "next/link";
|
|
5
|
-
|
|
6
|
-
import { formatAreaM2 } from "../presentation";
|
|
7
|
-
import { toListingCardModel } from "../listing-card-model";
|
|
8
|
-
import type { Listing } from "../types";
|
|
9
|
-
import { cn } from "./cn";
|
|
10
|
-
import { SearchChromeStyles } from "./styles";
|
|
11
|
-
import type { ListingCardProps } from "./types";
|
|
12
|
-
|
|
13
|
-
function isListing(value: ListingCardProps["listing"]): value is Listing {
|
|
14
|
-
return (
|
|
15
|
-
"priceVisibility" in value && "businessType" in value && "title" in value
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function ListingCard({
|
|
20
|
-
listing,
|
|
21
|
-
href,
|
|
22
|
-
className,
|
|
23
|
-
classNames,
|
|
24
|
-
slots,
|
|
25
|
-
style,
|
|
26
|
-
}: ListingCardProps): ReactElement {
|
|
27
|
-
const model = isListing(listing) ? toListingCardModel(listing) : listing;
|
|
28
|
-
const target = href ?? model.href;
|
|
29
|
-
const areaLabel = formatAreaM2(model.areaM2);
|
|
30
|
-
return (
|
|
31
|
-
<>
|
|
32
|
-
<SearchChromeStyles />
|
|
33
|
-
<article
|
|
34
|
-
data-slot="listing-card"
|
|
35
|
-
className={cn(className, classNames?.root)}
|
|
36
|
-
style={style}
|
|
37
|
-
>
|
|
38
|
-
<Link href={target} data-slot="listing-card-link">
|
|
39
|
-
<div data-slot="listing-card-media" className={classNames?.media}>
|
|
40
|
-
{slots?.media ??
|
|
41
|
-
(model.coverSrc ? (
|
|
42
|
-
<img src={model.coverSrc} alt={model.coverAlt} />
|
|
43
|
-
) : (
|
|
44
|
-
<div data-slot="listing-card-empty">Sem foto</div>
|
|
45
|
-
))}
|
|
46
|
-
{slots?.badge ?? (
|
|
47
|
-
<span
|
|
48
|
-
data-slot="listing-card-badge"
|
|
49
|
-
className={classNames?.badge}
|
|
50
|
-
>
|
|
51
|
-
{model.businessLabel}
|
|
52
|
-
</span>
|
|
53
|
-
)}
|
|
54
|
-
</div>
|
|
55
|
-
<div data-slot="listing-card-body" className={classNames?.body}>
|
|
56
|
-
<div data-slot="listing-card-price-row">
|
|
57
|
-
<p data-slot="listing-card-price" className={classNames?.price}>
|
|
58
|
-
{model.priceLabel}
|
|
59
|
-
</p>
|
|
60
|
-
{model.pricePeriod ? (
|
|
61
|
-
<span data-slot="listing-card-period">{model.pricePeriod}</span>
|
|
62
|
-
) : null}
|
|
63
|
-
</div>
|
|
64
|
-
<h3 data-slot="listing-card-title" className={classNames?.title}>
|
|
65
|
-
{model.title}
|
|
66
|
-
</h3>
|
|
67
|
-
<p
|
|
68
|
-
data-slot="listing-card-location"
|
|
69
|
-
className={classNames?.location}
|
|
70
|
-
>
|
|
71
|
-
{model.locationLabel || model.propertyType || ""}
|
|
72
|
-
</p>
|
|
73
|
-
<ul
|
|
74
|
-
data-slot="listing-card-features"
|
|
75
|
-
className={classNames?.features}
|
|
76
|
-
>
|
|
77
|
-
{model.bedrooms != null ? (
|
|
78
|
-
<li>{model.bedrooms} quartos</li>
|
|
79
|
-
) : null}
|
|
80
|
-
{model.bathrooms != null ? (
|
|
81
|
-
<li>{model.bathrooms} banheiros</li>
|
|
82
|
-
) : null}
|
|
83
|
-
{model.parkingSpaces != null ? (
|
|
84
|
-
<li>{model.parkingSpaces} vagas</li>
|
|
85
|
-
) : null}
|
|
86
|
-
{areaLabel ? <li>{areaLabel}</li> : null}
|
|
87
|
-
</ul>
|
|
88
|
-
{slots?.cta ? (
|
|
89
|
-
<div data-slot="listing-card-cta" className={classNames?.cta}>
|
|
90
|
-
{slots.cta}
|
|
91
|
-
</div>
|
|
92
|
-
) : null}
|
|
93
|
-
</div>
|
|
94
|
-
</Link>
|
|
95
|
-
</article>
|
|
96
|
-
</>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import type { CSSProperties, ReactElement } from "react";
|
|
4
|
-
|
|
5
|
-
import type { AmenityLabelDictionary } from "../amenity-labels";
|
|
6
|
-
import {
|
|
7
|
-
listingDetailFieldsModel,
|
|
8
|
-
type ListingDetailFieldsSource,
|
|
9
|
-
} from "../listing-detail-fields";
|
|
10
|
-
import { cn } from "./cn";
|
|
11
|
-
|
|
12
|
-
export type ListingDetailFieldsClassNames = {
|
|
13
|
-
root?: string;
|
|
14
|
-
facts?: string;
|
|
15
|
-
fact?: string;
|
|
16
|
-
values?: string;
|
|
17
|
-
value?: string;
|
|
18
|
-
amenityGroup?: string;
|
|
19
|
-
amenityTitle?: string;
|
|
20
|
-
amenityList?: string;
|
|
21
|
-
amenityLabel?: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type ListingDetailFieldsProps = {
|
|
25
|
-
listing: ListingDetailFieldsSource;
|
|
26
|
-
dictionary?: AmenityLabelDictionary | null;
|
|
27
|
-
className?: string;
|
|
28
|
-
classNames?: ListingDetailFieldsClassNames;
|
|
29
|
-
style?: CSSProperties;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Renders listing facts, values, and amenities. Omits empty rows so JSX
|
|
34
|
-
* never prints `undefined`. Theme via `data-slot` / classNames — do not
|
|
35
|
-
* reimplement these blocks in generated pages.
|
|
36
|
-
*/
|
|
37
|
-
export function ListingDetailFields({
|
|
38
|
-
listing,
|
|
39
|
-
dictionary,
|
|
40
|
-
className,
|
|
41
|
-
classNames,
|
|
42
|
-
style,
|
|
43
|
-
}: ListingDetailFieldsProps): ReactElement | null {
|
|
44
|
-
const model = listingDetailFieldsModel(listing, dictionary ?? undefined);
|
|
45
|
-
if (
|
|
46
|
-
model.facts.length === 0 &&
|
|
47
|
-
model.values.length === 0 &&
|
|
48
|
-
model.amenityGroups.length === 0
|
|
49
|
-
) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
return (
|
|
53
|
-
<div
|
|
54
|
-
data-slot="listing-detail-fields"
|
|
55
|
-
className={cn(className, classNames?.root)}
|
|
56
|
-
style={style}
|
|
57
|
-
>
|
|
58
|
-
{model.facts.length > 0 ? (
|
|
59
|
-
<ul data-slot="listing-facts" className={classNames?.facts}>
|
|
60
|
-
{model.facts.map((fact) => (
|
|
61
|
-
<li
|
|
62
|
-
key={fact.key}
|
|
63
|
-
data-slot="listing-fact"
|
|
64
|
-
data-key={fact.key}
|
|
65
|
-
className={classNames?.fact}
|
|
66
|
-
>
|
|
67
|
-
<span data-slot="listing-fact-label">{fact.label}</span>
|
|
68
|
-
<span data-slot="listing-fact-text">{fact.text}</span>
|
|
69
|
-
</li>
|
|
70
|
-
))}
|
|
71
|
-
</ul>
|
|
72
|
-
) : null}
|
|
73
|
-
{model.values.length > 0 ? (
|
|
74
|
-
<dl data-slot="listing-values" className={classNames?.values}>
|
|
75
|
-
{model.values.map((value) => (
|
|
76
|
-
<div
|
|
77
|
-
key={value.key}
|
|
78
|
-
data-slot="listing-value"
|
|
79
|
-
data-key={value.key}
|
|
80
|
-
className={classNames?.value}
|
|
81
|
-
>
|
|
82
|
-
<dt data-slot="listing-value-label">{value.label}</dt>
|
|
83
|
-
<dd data-slot="listing-value-text">{value.text}</dd>
|
|
84
|
-
</div>
|
|
85
|
-
))}
|
|
86
|
-
</dl>
|
|
87
|
-
) : null}
|
|
88
|
-
{model.amenityGroups.map((group) => (
|
|
89
|
-
<section
|
|
90
|
-
key={group.key}
|
|
91
|
-
data-slot="listing-amenities"
|
|
92
|
-
data-key={group.key}
|
|
93
|
-
className={classNames?.amenityGroup}
|
|
94
|
-
>
|
|
95
|
-
<h2
|
|
96
|
-
data-slot="listing-amenities-title"
|
|
97
|
-
className={classNames?.amenityTitle}
|
|
98
|
-
>
|
|
99
|
-
{group.title}
|
|
100
|
-
</h2>
|
|
101
|
-
<ul
|
|
102
|
-
data-slot="listing-amenities-list"
|
|
103
|
-
className={classNames?.amenityList}
|
|
104
|
-
>
|
|
105
|
-
{group.labels.map((label) => (
|
|
106
|
-
<li
|
|
107
|
-
key={label}
|
|
108
|
-
data-slot="listing-amenity-label"
|
|
109
|
-
className={classNames?.amenityLabel}
|
|
110
|
-
>
|
|
111
|
-
{label}
|
|
112
|
-
</li>
|
|
113
|
-
))}
|
|
114
|
-
</ul>
|
|
115
|
-
</section>
|
|
116
|
-
))}
|
|
117
|
-
</div>
|
|
118
|
-
);
|
|
119
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import type { ReactElement } from "react";
|
|
4
|
-
|
|
5
|
-
import { SearchChromeStyles } from "./styles";
|
|
6
|
-
|
|
7
|
-
export function ResultsSkeleton({
|
|
8
|
-
className,
|
|
9
|
-
}: {
|
|
10
|
-
className?: string;
|
|
11
|
-
}): ReactElement {
|
|
12
|
-
return (
|
|
13
|
-
<>
|
|
14
|
-
<SearchChromeStyles />
|
|
15
|
-
<div data-slot="search-skeleton" className={className}>
|
|
16
|
-
{Array.from({ length: 6 }, (_, i) => (
|
|
17
|
-
<div key={i} data-slot="search-skeleton-card">
|
|
18
|
-
<div data-slot="search-skeleton-block" data-kind="media" />
|
|
19
|
-
<div data-slot="search-skeleton-body">
|
|
20
|
-
<div data-slot="search-skeleton-block" data-kind="line-lg" />
|
|
21
|
-
<div data-slot="search-skeleton-block" data-kind="line-md" />
|
|
22
|
-
<div data-slot="search-skeleton-block" data-kind="line-sm" />
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
))}
|
|
26
|
-
</div>
|
|
27
|
-
</>
|
|
28
|
-
);
|
|
29
|
-
}
|