@garagem-ai/site-sdk 0.5.2 → 0.6.0
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 +296 -28
- package/dist/index.d.ts +296 -28
- package/dist/index.js +469 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +458 -51
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +18 -60
- package/dist/react.d.ts +18 -60
- package/dist/react.js +265 -874
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +246 -841
- package/dist/react.mjs.map +1 -1
- package/dist/{search-engine-4ocM0UPk.d.mts → search-engine-CtnLzmwW.d.mts} +13 -181
- package/dist/{search-engine-4ocM0UPk.d.ts → search-engine-CtnLzmwW.d.ts} +13 -181
- package/package.json +11 -13
- package/src/amenity-labels.ts +9 -2
- package/src/fetchers.ts +2 -1
- package/src/index.ts +20 -2
- package/src/internal/url.ts +1 -0
- package/src/leads.ts +45 -6
- package/src/listing-card-model.ts +4 -1
- package/src/listing-detail.ts +8 -2
- package/src/phone-countries.ts +97 -0
- package/src/phone.ts +431 -0
- package/src/presentation.ts +1 -24
- package/src/react/index.ts +1 -11
- package/src/react/public-search-snapshot.ts +165 -0
- package/src/react/staged-filters-mirror.ts +38 -0
- package/src/react/types.ts +17 -30
- package/src/react/use-public-search.ts +121 -42
- package/src/search-engine.ts +3 -0
- package/src/studio-contract.ts +63 -21
- package/src/types.ts +12 -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/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,36 @@ 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,
|
|
77
|
+
/**
|
|
78
|
+
* Prompt-safe phone helpers on `minNpmVersion`. Empty until a published
|
|
79
|
+
* tarball exports them and this pin bumps — then move names here from
|
|
80
|
+
* `unpublishedPhoneExports`.
|
|
81
|
+
*/
|
|
82
|
+
phoneExports: [] as const,
|
|
83
|
+
/**
|
|
84
|
+
* Headless phone mask helpers in git / newer tarballs but not on
|
|
85
|
+
* `minNpmVersion` (0.4.12). Prompts, completeness, and repair text must
|
|
86
|
+
* not mention these until the pin bumps — v0 installs the pin and the
|
|
87
|
+
* ESM loader throws on missing named exports.
|
|
88
|
+
*/
|
|
89
|
+
unpublishedPhoneExports: [
|
|
90
|
+
"PHONE_COUNTRIES",
|
|
91
|
+
"formatPhoneNational",
|
|
92
|
+
"toE164",
|
|
93
|
+
"isValidPhone",
|
|
94
|
+
"parsePhoneInput",
|
|
95
|
+
"phoneCountrySearchValue",
|
|
96
|
+
"findPhoneCountry",
|
|
97
|
+
"remaskPhoneForCountry",
|
|
98
|
+
] as const,
|
|
67
99
|
amenityExports: ["listingAmenityGroups"] as const,
|
|
68
100
|
/**
|
|
69
101
|
* Names already on the pinned npm tarball (`minNpmVersion` / 0.4.12) —
|
|
@@ -129,7 +161,7 @@ Every page section is two layers: (1) surface — \`section\` / header / footer
|
|
|
129
161
|
}
|
|
130
162
|
|
|
131
163
|
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}\`.
|
|
164
|
+
return `Search at \`/imoveis\` (hard rule). The page landmark is \`<main className="${STUDIO_SITE_LAYOUT.searchMainClassName}">\` with one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`. The server page awaits the catalog and renders it with \`usePublicSearch\` from \`${STUDIO_SDK_PACKAGE}/react\` (\`search\` from the page searchParams, plus \`initial\`). Do not wrap that UI in \`<Suspense>\` and do not add a route \`loading\` file. A suspended page is streamed into a hidden node and stays invisible until JavaScript runs. 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
165
|
}
|
|
134
166
|
|
|
135
167
|
const REACT_SDK_NAMED_IMPORT_RE =
|
|
@@ -205,26 +237,31 @@ export function studioSdkPinInstruction(): string {
|
|
|
205
237
|
|
|
206
238
|
export function studioLeadInstruction(): string {
|
|
207
239
|
const names = STUDIO_SDK_CONTRACT.leadExports.join(", ");
|
|
208
|
-
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.`;
|
|
240
|
+
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. Phone fields use a national mask with a country picker and submit E.164 — do not invent a second mask and do not import \`@garagem/ui\` PhoneInput.`;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export function studioListingCardInstruction(): string {
|
|
244
|
+
const names = STUDIO_SDK_CONTRACT.listingCardExports.join(", ");
|
|
245
|
+
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\` only for a slot whose content is still unknown — never as a \`<Suspense>\` fallback that replaces the catalog, and never the text “Carregando imóveis…”. Do not \`if (search.loading) return\` that skeleton inside the search client.`;
|
|
209
246
|
}
|
|
210
247
|
|
|
211
248
|
export function studioListingDetailInstruction(): string {
|
|
212
249
|
const names = STUDIO_SDK_CONTRACT.listingDetailExports.join(", ");
|
|
213
|
-
return `Listing detail: import ${names} from \`${STUDIO_SDK_PACKAGE}
|
|
250
|
+
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
251
|
}
|
|
215
252
|
|
|
216
253
|
export function studioAmenityInstruction(): string {
|
|
217
|
-
return `Listing amenities: Portuguese labels from \`listingAmenityGroups(listing)\` (
|
|
254
|
+
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
255
|
}
|
|
219
256
|
|
|
220
257
|
export function studioSearchInstruction(): string {
|
|
221
258
|
const reactNames = STUDIO_SDK_CONTRACT.reactExports.join(", ");
|
|
222
259
|
const libNames = STUDIO_SDK_CONTRACT.searchExports.join(", ");
|
|
223
|
-
return `Search: import ${reactNames} from \`${STUDIO_SDK_PACKAGE}/react\`. From \`${STUDIO_SDK_PACKAGE}\` import ${libNames}.
|
|
260
|
+
return `Search: import ${reactNames} from \`${STUDIO_SDK_PACKAGE}/react\`. From \`${STUDIO_SDK_PACKAGE}\` import ${libNames}. Prefetch \`getSearchUi\` + \`queryListings\` on the server page. \`const search = usePublicSearch({ siteId, baseUrl: GARAGEM_API_BASE, search: searchFromServer, initial })\` where \`searchFromServer\` is \`new URLSearchParams(await searchParams).toString()\` — never shorthand \`{ search }\` beside \`const search =\` (temporal dead zone). Do not wrap this UI in \`<Suspense>\` and do not add a route \`loading\` file — heading and cards are ordinary elements in the document, visible with JavaScript off. 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 only for a slot whose content is still unknown, never as a 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
261
|
}
|
|
225
262
|
|
|
226
263
|
export function studioChromeInstruction(): string {
|
|
227
|
-
return `
|
|
264
|
+
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
265
|
}
|
|
229
266
|
|
|
230
267
|
function mentionsExportName(text: string, name: string): boolean {
|
|
@@ -250,6 +287,11 @@ export function studioCodegenContractViolations(text: string): string[] {
|
|
|
250
287
|
violations.push(name);
|
|
251
288
|
}
|
|
252
289
|
}
|
|
290
|
+
for (const name of STUDIO_SDK_CONTRACT.unpublishedPhoneExports) {
|
|
291
|
+
if (mentionsExportName(text, name) && !violations.includes(name)) {
|
|
292
|
+
violations.push(name);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
253
295
|
const pin = STUDIO_SDK_CONTRACT.minNpmVersion;
|
|
254
296
|
const available = reactExportsAvailableAt(pin);
|
|
255
297
|
for (const name of parseReactSdkNamedImports(text)) {
|
package/src/types.ts
CHANGED
|
@@ -84,6 +84,8 @@ export interface Listing {
|
|
|
84
84
|
description: string;
|
|
85
85
|
businessType: ListingBusinessType;
|
|
86
86
|
price: number | null;
|
|
87
|
+
/** ISO 4217 currency code. Defaults to BRL when absent on older payloads. */
|
|
88
|
+
currency?: string;
|
|
87
89
|
priceVisibility: ListingPriceVisibility;
|
|
88
90
|
status: string;
|
|
89
91
|
featured: boolean;
|
|
@@ -102,6 +104,11 @@ export interface Listing {
|
|
|
102
104
|
* details and richer property info. Returned by `getListing`.
|
|
103
105
|
*/
|
|
104
106
|
export interface ListingDetail extends Listing {
|
|
107
|
+
/**
|
|
108
|
+
* Precomputed IPTU period label from tenant Campos (e.g. `IPTU/ano`,
|
|
109
|
+
* `IPTU/mês (10x)`). Render as-is; do not derive from raw period fields.
|
|
110
|
+
*/
|
|
111
|
+
propertyTaxLabel?: string;
|
|
105
112
|
/**
|
|
106
113
|
* Unit + building amenity ids (legacy merged list). Prefer
|
|
107
114
|
* `propertyFeatures` and `buildingAmenities` with `listingAmenityGroups`.
|
|
@@ -176,6 +183,11 @@ export type SearchUiDictionary = {
|
|
|
176
183
|
propertyTypes: SearchUiOption[];
|
|
177
184
|
propertyFeatures: SearchUiOption[];
|
|
178
185
|
buildingAmenities: SearchUiOption[];
|
|
186
|
+
/** Present only when Campos amenity display is flat (checkbox / alphabetical). */
|
|
187
|
+
amenitySectionTitles?: {
|
|
188
|
+
unit?: string;
|
|
189
|
+
building?: string;
|
|
190
|
+
};
|
|
179
191
|
};
|
|
180
192
|
|
|
181
193
|
/** 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
|
-
}
|
package/src/react/search.css
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Card + skeleton CSS for published Studio sites.
|
|
3
|
-
* Layout does not depend on the app Tailwind scan of node_modules.
|
|
4
|
-
* Brand color/radius come from the site theme (`--background`, `--primary`, …).
|
|
5
|
-
* Search chrome (query, toolbar, sort, filters, pagination) is app-owned.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
:root {
|
|
9
|
-
--garagem-listing-card-radius: 0.75rem;
|
|
10
|
-
--garagem-listing-card-gap: 1.5rem;
|
|
11
|
-
--garagem-listing-price-size: 1.125rem;
|
|
12
|
-
--garagem-listing-media-ratio: 4 / 3;
|
|
13
|
-
--garagem-skeleton: var(--muted, #e7e5e4);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
[data-slot="search-grid"],
|
|
17
|
-
[data-slot="search-skeleton"] {
|
|
18
|
-
display: grid;
|
|
19
|
-
grid-template-columns: 1fr;
|
|
20
|
-
gap: var(--garagem-listing-card-gap);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@media (min-width: 640px) {
|
|
24
|
-
[data-slot="search-grid"],
|
|
25
|
-
[data-slot="search-skeleton"] {
|
|
26
|
-
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@media (min-width: 1024px) {
|
|
31
|
-
[data-slot="search-grid"],
|
|
32
|
-
[data-slot="search-skeleton"] {
|
|
33
|
-
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
[data-slot="listing-card"] {
|
|
38
|
-
overflow: hidden;
|
|
39
|
-
border-radius: var(--garagem-listing-card-radius);
|
|
40
|
-
border: 1px solid var(--border, #e4e4e7);
|
|
41
|
-
background: var(--card, var(--background, #fff));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
[data-slot="listing-card-price-row"] {
|
|
45
|
-
display: inline-flex;
|
|
46
|
-
align-items: baseline;
|
|
47
|
-
gap: 0.25rem;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
[data-slot="listing-card-price"] {
|
|
51
|
-
font-size: var(--garagem-listing-price-size);
|
|
52
|
-
font-weight: 600;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
[data-slot="listing-card-period"] {
|
|
56
|
-
font-size: 0.75rem;
|
|
57
|
-
color: var(--muted-foreground, #737373);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
[data-slot="listing-card-link"] {
|
|
61
|
-
display: block;
|
|
62
|
-
color: inherit;
|
|
63
|
-
text-decoration: none;
|
|
64
|
-
cursor: pointer;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
[data-slot="listing-card-media"] {
|
|
68
|
-
position: relative;
|
|
69
|
-
width: 100%;
|
|
70
|
-
overflow: hidden;
|
|
71
|
-
background: var(--muted, #f5f5f4);
|
|
72
|
-
aspect-ratio: var(--garagem-listing-media-ratio);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
[data-slot="listing-card-media"] img {
|
|
76
|
-
height: 100%;
|
|
77
|
-
width: 100%;
|
|
78
|
-
object-fit: cover;
|
|
79
|
-
transition: transform 0.3s;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
[data-slot="listing-card"]:hover [data-slot="listing-card-media"] img {
|
|
83
|
-
transform: scale(1.05);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@media (prefers-reduced-motion: reduce) {
|
|
87
|
-
[data-slot="listing-card-media"] img {
|
|
88
|
-
transition: none;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
[data-slot="listing-card"]:hover [data-slot="listing-card-media"] img {
|
|
92
|
-
transform: none;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
[data-slot="listing-card-empty"] {
|
|
97
|
-
display: flex;
|
|
98
|
-
height: 100%;
|
|
99
|
-
width: 100%;
|
|
100
|
-
align-items: center;
|
|
101
|
-
justify-content: center;
|
|
102
|
-
font-size: 0.75rem;
|
|
103
|
-
color: var(--muted-foreground, #737373);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
[data-slot="listing-card-cta"] {
|
|
107
|
-
margin-top: 0.75rem;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
[data-slot="listing-card-badge"] {
|
|
111
|
-
position: absolute;
|
|
112
|
-
left: 0.75rem;
|
|
113
|
-
top: 0.75rem;
|
|
114
|
-
border-radius: 999px;
|
|
115
|
-
background: color-mix(in srgb, var(--background, #fff) 90%, transparent);
|
|
116
|
-
padding: 0.25rem 0.5rem;
|
|
117
|
-
font-size: 0.75rem;
|
|
118
|
-
font-weight: 500;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
[data-slot="listing-card-body"] {
|
|
122
|
-
padding: 1rem;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
[data-slot="listing-card-title"] {
|
|
126
|
-
display: -webkit-box;
|
|
127
|
-
margin-top: 0.25rem;
|
|
128
|
-
overflow: hidden;
|
|
129
|
-
-webkit-box-orient: vertical;
|
|
130
|
-
-webkit-line-clamp: 1;
|
|
131
|
-
font-size: 0.875rem;
|
|
132
|
-
font-weight: 500;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
[data-slot="listing-card-location"] {
|
|
136
|
-
margin-top: 0.125rem;
|
|
137
|
-
overflow: hidden;
|
|
138
|
-
text-overflow: ellipsis;
|
|
139
|
-
white-space: nowrap;
|
|
140
|
-
font-size: 0.75rem;
|
|
141
|
-
color: var(--muted-foreground, #737373);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
[data-slot="listing-card-features"] {
|
|
145
|
-
display: flex;
|
|
146
|
-
flex-wrap: wrap;
|
|
147
|
-
margin-top: 0.75rem;
|
|
148
|
-
gap: 0.25rem 1rem;
|
|
149
|
-
padding: 0;
|
|
150
|
-
list-style: none;
|
|
151
|
-
font-size: 0.75rem;
|
|
152
|
-
color: var(--muted-foreground, #737373);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
[data-slot="search-skeleton-block"] {
|
|
156
|
-
animation: garagem-search-pulse 1.2s ease-in-out infinite;
|
|
157
|
-
background: var(--garagem-skeleton);
|
|
158
|
-
border-radius: 0.375rem;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
[data-slot="search-skeleton-card"] {
|
|
162
|
-
overflow: hidden;
|
|
163
|
-
border-radius: var(--garagem-listing-card-radius);
|
|
164
|
-
border: 1px solid var(--border, #e4e4e7);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
[data-slot="search-skeleton-body"] {
|
|
168
|
-
display: flex;
|
|
169
|
-
flex-direction: column;
|
|
170
|
-
gap: 0.5rem;
|
|
171
|
-
padding: 1rem;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
[data-slot="search-skeleton-block"][data-kind="media"] {
|
|
175
|
-
aspect-ratio: var(--garagem-listing-media-ratio);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
[data-slot="search-skeleton-block"][data-kind="line-lg"] {
|
|
179
|
-
height: 1.25rem;
|
|
180
|
-
width: 50%;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
[data-slot="search-skeleton-block"][data-kind="line-md"] {
|
|
184
|
-
height: 1rem;
|
|
185
|
-
width: 75%;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
[data-slot="search-skeleton-block"][data-kind="line-sm"] {
|
|
189
|
-
height: 0.75rem;
|
|
190
|
-
width: 66.666667%;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
[data-slot="search-skeleton-block"][data-kind="detail-media"] {
|
|
194
|
-
max-width: 45rem;
|
|
195
|
-
aspect-ratio: 4 / 3;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
[data-slot="search-skeleton-block"][data-kind="detail-title"] {
|
|
199
|
-
width: 66.666667%;
|
|
200
|
-
height: 2rem;
|
|
201
|
-
margin-top: 1.5rem;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
@media (prefers-reduced-motion: reduce) {
|
|
205
|
-
[data-slot="search-skeleton-block"] {
|
|
206
|
-
animation: none;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
@keyframes garagem-search-pulse {
|
|
211
|
-
50% {
|
|
212
|
-
opacity: 0.55;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SearchChromeStyles } from "./search-chrome-styles";
|