@garagem-ai/site-sdk 0.5.1 → 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.
@@ -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 [staged, setStaged] = useState<SearchPathFilters>({});
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
- setStaged({ ...parsed.pathFilters });
71
- }, [parsed.pathFilters]);
76
+ replaceStaged({ ...parsed.pathFilters });
77
+ }, [parsed.pathFilters, replaceStaged]);
72
78
 
73
79
  useEffect(() => {
74
- setStaged({ ...parsed.pathFilters });
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
- setStaged((current) => applyPathFilter(current, filterId, value));
233
+ setStagedState(stagedMirrorRef.current.stage(filterId, value));
221
234
  }, []);
222
235
 
223
236
  const applyStaged = useCallback(() => {
224
237
  if (!schema) return;
225
- go(hrefForPathFilters(pathname, search, schema.dictionary, staged));
226
- }, [go, pathname, search, schema, staged]);
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
- setStaged((current) => clearStagedPathFilters(current));
249
+ setStagedState(stagedMirrorRef.current.clear());
230
250
  }, []);
231
251
 
232
252
  const submitQuery = useCallback(() => {
@@ -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,
@@ -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. Optional exports exist
7
- * in git and may already be on npm, but Studio codegen must not name them
8
- * while chromeStrategy is self-inject (v0 copies identifiers; a layout tag
9
- * also breaks the pancake stack).
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
- /** First release where ListingCard and ResultsSkeleton inject card CSS. */
26
+ /** Historical: older tarballs inject card CSS when those components mount. */
27
27
  selfInjectSince: "0.4.2",
28
- chromeStrategy: "self-inject" as const,
29
- reactExports: ["usePublicSearch", "ListingCard", "ResultsSkeleton"] as const,
28
+ chromeStrategy: "app-owned" as const,
29
+ reactExports: ["usePublicSearch"] as const,
30
30
  /**
31
- * Names that exist in git / the unpublished patch. Completeness treats an
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. Completeness flags imports as mismatch (not in
43
- * `reactExports`). Prompts must not mention these names at all — v0 copies
44
- * identifiers even inside “never import”.
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={<ResultsSkeleton />}>\`. 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.`;
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}\` and \`ListingCard\` from \`${STUDIO_SDK_PACKAGE}/react\`. Render \`listingDetailModel\` leaves: \`model.facts[].label\` / \`.text\`, \`model.values[].label\` / \`.text\`, \`model.location.label\` / \`model.location.mapsHref\`, breadcrumb \`.href\` (search prefixes of \`listing.path\`). \`model.description\` is the complete string — do not slice. 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\`) and a fullscreen overlay that closes with browser back; omit when empty. Similar listings: \`getSimilarListings({ siteId, listingId, baseUrl })\` + \`ListingCard\`; hide the section when empty. Do not invent a local recommendation loop.`;
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)\` (optional dictionary from \`getSearchUi()\`). Each group is \`{ title, labels: string[] }\` — render \`group.labels.map((label) => …)\` and hide a group when \`group.labels.length === 0\`. Titles: \`Comodidades\` / \`Comodidades do condomínio\`. Never print amenity ids, never invent a local label map, and never title a section "Comodidades da unidade".`;
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\`), grid (\`listings.map\` + \`ListingCard\`; \`ResultsSkeleton\` is only the Suspense fallback), pagination (\`paginationPages\` + \`hrefWithExplicitPage\`). Never interpolate \`schema\`, \`pathFilters\`, or a filter object as a React child. \`queryListings\` key is \`params\`. The URL is the document. Empty copy: ${JSON.stringify(SEARCH_EMPTY_COPY)}`;
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 `ListingCard and ResultsSkeleton inject card/skeleton CSS (JS \`<style>\` tag). Never \`import "${STUDIO_SDK_CONTRACT.forbiddenImports[0]}"\` — v0 preview cannot load npm CSS. Do not copy SDK card layout into the app. Theme cards via CSS variables in \`app/globals.css\` (\`SEARCH_CSS_RECIPE\` / \`--garagem-*\`). Search chrome (query, toolbar, sort, filters, pagination) is app-owned — theme with the site tokens, not an SDK stylesheet.`;
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,3 +0,0 @@
1
- export function cn(...parts: Array<string | false | null | undefined>): string {
2
- return parts.filter(Boolean).join(" ");
3
- }
@@ -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
- }