@garagem-ai/site-sdk 0.4.12 → 0.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2161,32 +2161,56 @@ function listingMediaOverlays(listing) {
2161
2161
  return overlays;
2162
2162
  }
2163
2163
  function listingDetailModel(listing, options) {
2164
- const descriptionPreview = listingDescriptionPreview(
2165
- listing.description,
2166
- options?.descriptionExpanded === true
2167
- );
2164
+ const text = listing.description?.trim() ?? "";
2165
+ const description = text || null;
2166
+ const truncated = description != null && description.length > LISTING_DESCRIPTION_CLAMP;
2167
+ const expanded = options?.descriptionExpanded === true;
2168
2168
  return {
2169
2169
  breadcrumb: listingBreadcrumb(listing),
2170
2170
  values: listingValues(listing),
2171
2171
  facts: listingFacts(listing),
2172
2172
  location: listingLocationBlock(listing),
2173
- /** Clamped (or full) copy — a string so JSX `{model.description}` is safe. */
2174
- description: descriptionPreview?.text ?? null,
2175
- descriptionTruncated: descriptionPreview?.truncated === true,
2176
- descriptionToggleLabel: descriptionPreview?.toggleLabel ?? null,
2173
+ description,
2174
+ descriptionTruncated: truncated,
2175
+ descriptionToggleLabel: truncated ? expanded ? "Ler menos" : "Ler mais" : null,
2177
2176
  mediaOverlays: listingMediaOverlays(listing)
2178
2177
  };
2179
2178
  }
2180
2179
 
2180
+ // src/listing-detail-fields.ts
2181
+ function visibleText(value) {
2182
+ if (typeof value !== "string") return null;
2183
+ const trimmed = value.trim();
2184
+ if (!trimmed || trimmed === "undefined" || trimmed === "null") return null;
2185
+ return trimmed;
2186
+ }
2187
+ function visibleRows(rows) {
2188
+ return rows.filter((row) => {
2189
+ const label = visibleText(row.label);
2190
+ const text = visibleText(row.text);
2191
+ return label != null && text != null;
2192
+ });
2193
+ }
2194
+ function listingDetailFieldsModel(listing, dictionary) {
2195
+ return {
2196
+ facts: visibleRows(listingFacts(listing)),
2197
+ values: visibleRows(listingValues(listing)),
2198
+ amenityGroups: listingAmenityGroups(listing, dictionary).map((group) => ({
2199
+ ...group,
2200
+ labels: group.labels.map((label) => visibleText(label)).filter((label) => label != null)
2201
+ })).filter((group) => group.labels.length > 0)
2202
+ };
2203
+ }
2204
+
2181
2205
  // src/studio-contract.ts
2182
2206
  var STUDIO_SDK_PACKAGE = "@garagem-ai/site-sdk";
2183
2207
  var STUDIO_SDK_CONTRACT = {
2184
2208
  package: STUDIO_SDK_PACKAGE,
2185
2209
  /**
2186
- * Exact pin for generated Studio sites. Must be ≥ `selfInjectSince` so
2187
- * prompts that skip the layout chrome tag match the tarball v0 installs.
2188
- * 0.4.12 flattens listingDetailModel.description to a string (plus
2189
- * descriptionToggleLabel) so JSX cannot render the clamp object.
2210
+ * Exact pin for generated Studio sites. Must match a tarball already on
2211
+ * npm — v0 installs this version. After the 0.4.13 changeset publishes,
2212
+ * bump this and move that release's names from `optionalReactExports`
2213
+ * into `reactExports`.
2190
2214
  */
2191
2215
  minNpmVersion: "0.4.12",
2192
2216
  /** First release where ListingCard and ResultsSkeleton inject the sheet. */
@@ -2207,7 +2231,8 @@ var STUDIO_SDK_CONTRACT = {
2207
2231
  */
2208
2232
  optionalReactExports: {
2209
2233
  SearchPageFallback: "0.4.1",
2210
- SearchChromeStyles: "0.4.1"
2234
+ SearchChromeStyles: "0.4.1",
2235
+ ListingDetailFields: "0.4.13"
2211
2236
  },
2212
2237
  forbiddenImports: ["@garagem-ai/site-sdk/react/search.css"],
2213
2238
  leadStrategy: "visit-default",
@@ -2251,7 +2276,7 @@ ${studioSiteWidthCss()}
2251
2276
  Every page section is two layers: (1) surface \u2014 \`section\` / header / footer \`${STUDIO_SITE_LAYOUT.surfaceClassName}\`, background to the viewport edges, no max-width class and no horizontal padding; (2) wrapper \u2014 one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`. Header and footer use that same inner wrapper. Components fill the wrapper (\`w-full\`). Never nest a second max-width container with extra horizontal padding. ${studioSearchLandmarkInstruction()} Do not use \`ml-auto\` on the content wrapper. To make the site narrower or wider, change ONLY \`--site-max-width\` in \`app/globals.css\` (allowed: ${scale}; default ${STUDIO_SITE_LAYOUT.maxWidthRem}). Do not edit wrapper class names or horizontal padding. Full-bleed image surfaces (home hero, listing gallery) stay flush with the header \u2014 do not add vertical padding there.`;
2252
2277
  }
2253
2278
  function studioSearchLandmarkInstruction() {
2254
- return `Search at \`/imoveis\` (hard rule). The page landmark is \`<main className="${STUDIO_SITE_LAYOUT.searchMainClassName}">\` with one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`. Pass \`as="div"\` to \`SearchPage\` so it is not a second main. Do not wrap \`SearchPage\` in \`<section>\`. Do not put vertical padding on SearchPage. \`pt-4 pb-12\` is the default on that search \`<main>\` \u2014 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.`;
2279
+ return `Search at \`/imoveis\` (hard rule). The page landmark is \`<main className="${STUDIO_SITE_LAYOUT.searchMainClassName}">\` with one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`. Pass \`as="div"\` to \`SearchPage\` so it is not a second main. Mount as one line: \`<SearchPage as="div" siteId={() => resolveSiteId(window.location.host)} baseUrl={GARAGEM_API_BASE} variant="toolbar" />\`. Do not wrap \`SearchPage\` in \`<section>\` or add another \`<h1>\`. SearchPage owns the SEO heading: count in \`data-slot="search-heading-count"\` (sibling \`<span>\`), title in \`<h1 data-slot="search-heading-title">\` \u2014 never put the count inside the H1. Do not put vertical padding on SearchPage. \`pt-4 pb-12\` is the default on that search \`<main>\` \u2014 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.`;
2255
2280
  }
2256
2281
  var REACT_SDK_NAMED_IMPORT_RE = /(?:^|[\n;])\s*import\s+(?!type\b)(?:type\s+)?\{([^}]+)\}\s+from\s+['"]@garagem-ai\/site-sdk\/react['"]/g;
2257
2282
  var SHOWCASE_LEADS_POST_URL_RE = /\/api\/sites\/[^\s"']*\/leads(?!\/ui)/;
@@ -2318,11 +2343,10 @@ function studioLeadInstruction() {
2318
2343
  }
2319
2344
  function studioListingDetailInstruction() {
2320
2345
  const names = STUDIO_SDK_CONTRACT.listingDetailExports.join(", ");
2321
- return `Listing detail blocks: import ${names} from \`${STUDIO_SDK_PACKAGE}\` and \`ListingCard\` from \`${STUDIO_SDK_PACKAGE}/react\`. Render \`listingDetailModel(listing)\` for breadcrumb (hrefs are search prefixes of \`listing.path\`, never invented paths), values (price / sob consulta, condo, IPTU), facts (omit empty zeros; bedrooms \u2260 salas), location plus a discreet Google Maps \`<a target="_blank" rel="noopener noreferrer">\`, and description as the string \`model.description\` plus \`model.descriptionToggleLabel\` (keep the full text; do not drop the remainder). Map facts/values/breadcrumb items to \`.label\` / \`.text\` / \`.href\`; use \`model.location.label\` and \`model.location.mapsHref\`. Never interpolate \`model.location\`, \`model.facts\`, \`model.values\`, \`model.breadcrumb\`, \`model.mediaOverlays\`, or amenity groups 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 the list is empty. Do not invent a local recommendation loop.`;
2346
+ 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 \u2014 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.`;
2322
2347
  }
2323
2348
  function studioAmenityInstruction() {
2324
- const names = STUDIO_SDK_CONTRACT.amenityExports.join(", ");
2325
- return `Listing amenities: import ${names} from \`${STUDIO_SDK_PACKAGE}\`. Render \`listingAmenityGroups(listing)\` (optional second arg: \`getSearchUi().dictionary\`). Use the helper titles (\`Comodidades\` / \`Comodidades do condom\xEDnio\`). Labels are already alphabetical (pt-BR) \u2014 keep that order. Omit empty groups. Never print amenity ids, never invent a local label map, and never title a section "Comodidades da unidade".`;
2349
+ return `Listing amenities: Portuguese labels from \`listingAmenityGroups(listing)\` (optional dictionary from \`getSearchUi()\`). Titles: \`Comodidades\` / \`Comodidades do condom\xEDnio\`. Never print amenity ids, never invent a local label map, and never title a section "Comodidades da unidade".`;
2326
2350
  }
2327
2351
  function studioChromeInstruction() {
2328
2352
  const injectors = compareSemver(
@@ -2562,6 +2586,7 @@ export {
2562
2586
  listingBreadcrumb,
2563
2587
  listingBusinessLabel,
2564
2588
  listingDescriptionPreview,
2589
+ listingDetailFieldsModel,
2565
2590
  listingDetailModel,
2566
2591
  listingFacts,
2567
2592
  listingLocationBlock,