@garagem-ai/site-sdk 0.4.11 → 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/README.md +29 -25
- package/dist/index.d.mts +9 -129
- package/dist/index.d.ts +9 -129
- package/dist/index.js +44 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -15
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +28 -2
- package/dist/react.d.ts +28 -2
- package/dist/react.js +645 -109
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +649 -114
- package/dist/react.mjs.map +1 -1
- package/dist/{search-engine-B83s_fVd.d.mts → search-engine-1O4sKtKb.d.mts} +141 -1
- package/dist/{search-engine-B83s_fVd.d.ts → search-engine-1O4sKtKb.d.ts} +141 -1
- package/package.json +1 -1
- package/src/index.ts +7 -0
- package/src/listing-detail-fields.ts +59 -0
- package/src/listing-detail.ts +27 -5
- package/src/react/index.ts +5 -0
- package/src/react/listing-detail-fields.tsx +119 -0
- package/src/react/search-page.tsx +7 -0
- package/src/react/styles/search-chrome-css.generated.ts +1 -1
- package/src/react/types.ts +1 -0
- package/src/studio-contract.ts +9 -10
package/dist/index.mjs
CHANGED
|
@@ -2161,31 +2161,58 @@ function listingMediaOverlays(listing) {
|
|
|
2161
2161
|
return overlays;
|
|
2162
2162
|
}
|
|
2163
2163
|
function listingDetailModel(listing, options) {
|
|
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;
|
|
2164
2168
|
return {
|
|
2165
2169
|
breadcrumb: listingBreadcrumb(listing),
|
|
2166
2170
|
values: listingValues(listing),
|
|
2167
2171
|
facts: listingFacts(listing),
|
|
2168
2172
|
location: listingLocationBlock(listing),
|
|
2169
|
-
description
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
),
|
|
2173
|
+
description,
|
|
2174
|
+
descriptionTruncated: truncated,
|
|
2175
|
+
descriptionToggleLabel: truncated ? expanded ? "Ler menos" : "Ler mais" : null,
|
|
2173
2176
|
mediaOverlays: listingMediaOverlays(listing)
|
|
2174
2177
|
};
|
|
2175
2178
|
}
|
|
2176
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
|
+
|
|
2177
2205
|
// src/studio-contract.ts
|
|
2178
2206
|
var STUDIO_SDK_PACKAGE = "@garagem-ai/site-sdk";
|
|
2179
2207
|
var STUDIO_SDK_CONTRACT = {
|
|
2180
2208
|
package: STUDIO_SDK_PACKAGE,
|
|
2181
2209
|
/**
|
|
2182
|
-
* Exact pin for generated Studio sites. Must
|
|
2183
|
-
*
|
|
2184
|
-
*
|
|
2185
|
-
*
|
|
2186
|
-
* listingAmenityGroups so listing detail never prints amenity ids.
|
|
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`.
|
|
2187
2214
|
*/
|
|
2188
|
-
minNpmVersion: "0.4.
|
|
2215
|
+
minNpmVersion: "0.4.12",
|
|
2189
2216
|
/** First release where ListingCard and ResultsSkeleton inject the sheet. */
|
|
2190
2217
|
selfInjectSince: "0.4.2",
|
|
2191
2218
|
chromeStrategy: "self-inject",
|
|
@@ -2204,7 +2231,8 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2204
2231
|
*/
|
|
2205
2232
|
optionalReactExports: {
|
|
2206
2233
|
SearchPageFallback: "0.4.1",
|
|
2207
|
-
SearchChromeStyles: "0.4.1"
|
|
2234
|
+
SearchChromeStyles: "0.4.1",
|
|
2235
|
+
ListingDetailFields: "0.4.13"
|
|
2208
2236
|
},
|
|
2209
2237
|
forbiddenImports: ["@garagem-ai/site-sdk/react/search.css"],
|
|
2210
2238
|
leadStrategy: "visit-default",
|
|
@@ -2248,7 +2276,7 @@ ${studioSiteWidthCss()}
|
|
|
2248
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.`;
|
|
2249
2277
|
}
|
|
2250
2278
|
function studioSearchLandmarkInstruction() {
|
|
2251
|
-
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.`;
|
|
2252
2280
|
}
|
|
2253
2281
|
var REACT_SDK_NAMED_IMPORT_RE = /(?:^|[\n;])\s*import\s+(?!type\b)(?:type\s+)?\{([^}]+)\}\s+from\s+['"]@garagem-ai\/site-sdk\/react['"]/g;
|
|
2254
2282
|
var SHOWCASE_LEADS_POST_URL_RE = /\/api\/sites\/[^\s"']*\/leads(?!\/ui)/;
|
|
@@ -2315,11 +2343,10 @@ function studioLeadInstruction() {
|
|
|
2315
2343
|
}
|
|
2316
2344
|
function studioListingDetailInstruction() {
|
|
2317
2345
|
const names = STUDIO_SDK_CONTRACT.listingDetailExports.join(", ");
|
|
2318
|
-
return `Listing detail
|
|
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.`;
|
|
2319
2347
|
}
|
|
2320
2348
|
function studioAmenityInstruction() {
|
|
2321
|
-
|
|
2322
|
-
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".`;
|
|
2323
2350
|
}
|
|
2324
2351
|
function studioChromeInstruction() {
|
|
2325
2352
|
const injectors = compareSemver(
|
|
@@ -2559,6 +2586,7 @@ export {
|
|
|
2559
2586
|
listingBreadcrumb,
|
|
2560
2587
|
listingBusinessLabel,
|
|
2561
2588
|
listingDescriptionPreview,
|
|
2589
|
+
listingDetailFieldsModel,
|
|
2562
2590
|
listingDetailModel,
|
|
2563
2591
|
listingFacts,
|
|
2564
2592
|
listingLocationBlock,
|