@garagem-ai/site-sdk 0.4.14 → 0.5.1
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 +26 -37
- package/dist/index.d.mts +31 -19
- package/dist/index.d.ts +31 -19
- package/dist/index.js +103 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -19
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +2 -98
- package/dist/react.d.ts +2 -98
- package/dist/react.js +11 -957
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +11 -955
- package/dist/react.mjs.map +1 -1
- package/dist/{search-engine-1O4sKtKb.d.mts → search-engine-4ocM0UPk.d.mts} +16 -1
- package/dist/{search-engine-1O4sKtKb.d.ts → search-engine-4ocM0UPk.d.ts} +16 -1
- package/package.json +2 -2
- package/src/index.ts +5 -0
- package/src/react/index.ts +1 -13
- package/src/react/search-chrome.tsx +0 -48
- package/src/react/search.css +2 -499
- package/src/react/styles/search-chrome-css.generated.ts +2 -2
- package/src/react/types.ts +0 -32
- package/src/search-engine.ts +47 -1
- package/src/studio-contract.ts +69 -21
- package/src/react/filter-panel.tsx +0 -248
- package/src/react/icons.tsx +0 -46
- package/src/react/search-page.tsx +0 -475
- package/src/react/search-pagination.tsx +0 -120
- package/src/react/search-query-form.tsx +0 -81
package/dist/index.mjs
CHANGED
|
@@ -1918,6 +1918,35 @@ function paginationPages(currentPage, totalPages, padding) {
|
|
|
1918
1918
|
for (let i = start; i <= end; i += 1) pages.push(i);
|
|
1919
1919
|
return pages;
|
|
1920
1920
|
}
|
|
1921
|
+
var SEARCH_EMPTY_COPY = "Nenhum im\xF3vel encontrado. Ajuste a busca ou os filtros.";
|
|
1922
|
+
function rangeDraftFromPath(pathFilters) {
|
|
1923
|
+
const price = pathFilters.price || {};
|
|
1924
|
+
const area = pathFilters.area || {};
|
|
1925
|
+
return {
|
|
1926
|
+
price: {
|
|
1927
|
+
min: price.min != null ? formatGroupedInteger(price.min) : "",
|
|
1928
|
+
max: price.max != null ? formatGroupedInteger(price.max) : ""
|
|
1929
|
+
},
|
|
1930
|
+
property_area_total: {
|
|
1931
|
+
min: area.min != null ? String(area.min) : "",
|
|
1932
|
+
max: area.max != null ? String(area.max) : ""
|
|
1933
|
+
}
|
|
1934
|
+
};
|
|
1935
|
+
}
|
|
1936
|
+
function searchChromeModel(schema, pathFilters, locationNames) {
|
|
1937
|
+
const filters = visibleSearchFilters(schema);
|
|
1938
|
+
const toolbarIds = new Set(toolbarFilterIds(schema));
|
|
1939
|
+
return {
|
|
1940
|
+
headingTitle: searchResultsHeading(
|
|
1941
|
+
pathFilters,
|
|
1942
|
+
schema?.dictionary,
|
|
1943
|
+
locationNames
|
|
1944
|
+
),
|
|
1945
|
+
toolbarFilters: filters.filter((filter) => toolbarIds.has(filter.id)),
|
|
1946
|
+
extraFilters: filters.filter((filter) => !toolbarIds.has(filter.id)),
|
|
1947
|
+
sortOptions: searchSortOptions(schema?.sorts)
|
|
1948
|
+
};
|
|
1949
|
+
}
|
|
1921
1950
|
|
|
1922
1951
|
// src/listing-detail.ts
|
|
1923
1952
|
var LISTING_DESCRIPTION_CLAMP = 280;
|
|
@@ -2208,20 +2237,17 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2208
2237
|
package: STUDIO_SDK_PACKAGE,
|
|
2209
2238
|
/**
|
|
2210
2239
|
* Exact pin for generated Studio sites. Must match a tarball already on
|
|
2211
|
-
* npm — v0 installs this version. After
|
|
2212
|
-
*
|
|
2213
|
-
* into
|
|
2240
|
+
* npm — v0 installs this version. After a later changeset publishes, bump
|
|
2241
|
+
* this and move that release's names from `optionalReactExports` /
|
|
2242
|
+
* `unpublishedSearchExports` into the prompt-safe lists. Do not bump here
|
|
2243
|
+
* until that tarball is on npm. Headless SearchPage already shipped in
|
|
2244
|
+
* 0.4.12 (`visibleSearchFilters` / `toolbarFilterIds` are on that pin).
|
|
2214
2245
|
*/
|
|
2215
2246
|
minNpmVersion: "0.4.12",
|
|
2216
|
-
/** First release where ListingCard and ResultsSkeleton inject
|
|
2247
|
+
/** First release where ListingCard and ResultsSkeleton inject card CSS. */
|
|
2217
2248
|
selfInjectSince: "0.4.2",
|
|
2218
2249
|
chromeStrategy: "self-inject",
|
|
2219
|
-
reactExports: [
|
|
2220
|
-
"SearchPage",
|
|
2221
|
-
"ListingCard",
|
|
2222
|
-
"usePublicSearch",
|
|
2223
|
-
"ResultsSkeleton"
|
|
2224
|
-
],
|
|
2250
|
+
reactExports: ["usePublicSearch", "ListingCard", "ResultsSkeleton"],
|
|
2225
2251
|
/**
|
|
2226
2252
|
* Names that exist in git / the unpublished patch. Completeness treats an
|
|
2227
2253
|
* import as `sdk-export-mismatch` when the generated pin is older than
|
|
@@ -2230,10 +2256,22 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2230
2256
|
* throws FatalRendererError.
|
|
2231
2257
|
*/
|
|
2232
2258
|
optionalReactExports: {
|
|
2233
|
-
SearchPageFallback: "0.4.1",
|
|
2234
2259
|
SearchChromeStyles: "0.4.1",
|
|
2235
2260
|
ListingDetailFields: "0.4.13"
|
|
2236
2261
|
},
|
|
2262
|
+
/**
|
|
2263
|
+
* Former `/react` chrome. Completeness flags imports as mismatch (not in
|
|
2264
|
+
* `reactExports`). Prompts must not mention these names at all — v0 copies
|
|
2265
|
+
* identifiers even inside “never import”.
|
|
2266
|
+
*/
|
|
2267
|
+
retiredReactExports: [
|
|
2268
|
+
"SearchPage",
|
|
2269
|
+
"SearchQueryForm",
|
|
2270
|
+
"SearchSortSelect",
|
|
2271
|
+
"FilterPanel",
|
|
2272
|
+
"SearchPagination",
|
|
2273
|
+
"SearchPageFallback"
|
|
2274
|
+
],
|
|
2237
2275
|
forbiddenImports: ["@garagem-ai/site-sdk/react/search.css"],
|
|
2238
2276
|
leadStrategy: "visit-default",
|
|
2239
2277
|
leadExports: [
|
|
@@ -2247,7 +2285,31 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2247
2285
|
"STUDIO_DEFAULT_VISIT_SCHEDULE"
|
|
2248
2286
|
],
|
|
2249
2287
|
listingDetailExports: ["listingDetailModel", "getSimilarListings"],
|
|
2250
|
-
amenityExports: ["listingAmenityGroups"]
|
|
2288
|
+
amenityExports: ["listingAmenityGroups"],
|
|
2289
|
+
/**
|
|
2290
|
+
* Names already on the pinned npm tarball (`minNpmVersion` / 0.4.12) —
|
|
2291
|
+
* safe for Studio prompts and completeness. Includes
|
|
2292
|
+
* `visibleSearchFilters` + `toolbarFilterIds` (shipped in 0.4.12). Do not
|
|
2293
|
+
* confuse with `unpublishedSearchExports` (`searchChromeModel`, …).
|
|
2294
|
+
*/
|
|
2295
|
+
searchExports: [
|
|
2296
|
+
"searchResultsHeading",
|
|
2297
|
+
"searchSortOptions",
|
|
2298
|
+
"visibleSearchFilters",
|
|
2299
|
+
"toolbarFilterIds",
|
|
2300
|
+
"paginationPages",
|
|
2301
|
+
"hrefWithExplicitPage"
|
|
2302
|
+
],
|
|
2303
|
+
/**
|
|
2304
|
+
* Main-package helpers in git / newer tarballs but not required on
|
|
2305
|
+
* `minNpmVersion`. Prompts must not mention these until the pin bumps and
|
|
2306
|
+
* they move into `searchExports`. Independent of the 0.4.12 filter helpers
|
|
2307
|
+
* already listed in `searchExports`.
|
|
2308
|
+
*/
|
|
2309
|
+
unpublishedSearchExports: [
|
|
2310
|
+
"searchChromeModel",
|
|
2311
|
+
"rangeDraftFromPath"
|
|
2312
|
+
]
|
|
2251
2313
|
};
|
|
2252
2314
|
var STUDIO_SITE_LAYOUT = {
|
|
2253
2315
|
maxWidthRem: "80rem",
|
|
@@ -2276,7 +2338,7 @@ ${studioSiteWidthCss()}
|
|
|
2276
2338
|
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.`;
|
|
2277
2339
|
}
|
|
2278
2340
|
function studioSearchLandmarkInstruction() {
|
|
2279
|
-
return `Search at \`/imoveis\` (hard rule). The page landmark is \`<main className="${STUDIO_SITE_LAYOUT.searchMainClassName}">\` with one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`.
|
|
2341
|
+
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">\` \u2014 never put the count inside the H1 and never put the h1 first. \`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.`;
|
|
2280
2342
|
}
|
|
2281
2343
|
var REACT_SDK_NAMED_IMPORT_RE = /(?:^|[\n;])\s*import\s+(?!type\b)(?:type\s+)?\{([^}]+)\}\s+from\s+['"]@garagem-ai\/site-sdk\/react['"]/g;
|
|
2282
2344
|
var SHOWCASE_LEADS_POST_URL_RE = /\/api\/sites\/[^\s"']*\/leads(?!\/ui)/;
|
|
@@ -2348,17 +2410,31 @@ function studioListingDetailInstruction() {
|
|
|
2348
2410
|
function studioAmenityInstruction() {
|
|
2349
2411
|
return `Listing amenities: Portuguese labels from \`listingAmenityGroups(listing)\` (optional dictionary from \`getSearchUi()\`). Each group is \`{ title, labels: string[] }\` \u2014 render \`group.labels.map((label) => \u2026)\` and hide a group when \`group.labels.length === 0\`. Titles: \`Comodidades\` / \`Comodidades do condom\xEDnio\`. Never print amenity ids, never invent a local label map, and never title a section "Comodidades da unidade".`;
|
|
2350
2412
|
}
|
|
2413
|
+
function studioSearchInstruction() {
|
|
2414
|
+
const reactNames = STUDIO_SDK_CONTRACT.reactExports.join(", ");
|
|
2415
|
+
const libNames = STUDIO_SDK_CONTRACT.searchExports.join(", ");
|
|
2416
|
+
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 \u2014 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)\` \u2014 never \`searchResultsHeading({})\`), toolbar (\`toolbarFilterIds\` + \`applyFilter\`; range \u201CAtualizar\u201D 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)}`;
|
|
2417
|
+
}
|
|
2351
2418
|
function studioChromeInstruction() {
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
return `Search chrome CSS is injected by ${injectors} (JS \`<style>\` tag). Never \`import "@garagem-ai/site-sdk/react/search.css"\` \u2014 v0 preview cannot load npm CSS. Do not copy SDK card/toolbar layout into the app. Theme via CSS variables in \`app/globals.css\` (\`SEARCH_CSS_RECIPE\` / \`--garagem-*\`), \`classNames\`, and \`data-slot\`.`;
|
|
2419
|
+
return `ListingCard and ResultsSkeleton inject card/skeleton CSS (JS \`<style>\` tag). Never \`import "${STUDIO_SDK_CONTRACT.forbiddenImports[0]}"\` \u2014 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 \u2014 theme with the site tokens, not an SDK stylesheet.`;
|
|
2420
|
+
}
|
|
2421
|
+
function mentionsExportName(text, name) {
|
|
2422
|
+
return new RegExp(`\\b${name}\\b`).test(text);
|
|
2357
2423
|
}
|
|
2358
2424
|
function studioCodegenContractViolations(text) {
|
|
2359
2425
|
const violations = [];
|
|
2360
2426
|
for (const name of Object.keys(STUDIO_SDK_CONTRACT.optionalReactExports)) {
|
|
2361
|
-
if (text
|
|
2427
|
+
if (mentionsExportName(text, name)) violations.push(name);
|
|
2428
|
+
}
|
|
2429
|
+
for (const name of STUDIO_SDK_CONTRACT.retiredReactExports) {
|
|
2430
|
+
if (mentionsExportName(text, name) && !violations.includes(name)) {
|
|
2431
|
+
violations.push(name);
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
for (const name of STUDIO_SDK_CONTRACT.unpublishedSearchExports) {
|
|
2435
|
+
if (mentionsExportName(text, name) && !violations.includes(name)) {
|
|
2436
|
+
violations.push(name);
|
|
2437
|
+
}
|
|
2362
2438
|
}
|
|
2363
2439
|
const pin = STUDIO_SDK_CONTRACT.minNpmVersion;
|
|
2364
2440
|
const available = reactExportsAvailableAt(pin);
|
|
@@ -2540,6 +2616,7 @@ export {
|
|
|
2540
2616
|
LeadSubmitError,
|
|
2541
2617
|
SEARCH_CSS_RECIPE,
|
|
2542
2618
|
SEARCH_CSS_VARS,
|
|
2619
|
+
SEARCH_EMPTY_COPY,
|
|
2543
2620
|
SEARCH_SORT_RELEVANCE,
|
|
2544
2621
|
STUDIO_DEFAULT_VISIT_SCHEDULE,
|
|
2545
2622
|
STUDIO_SDK_CONTRACT,
|
|
@@ -2610,9 +2687,11 @@ export {
|
|
|
2610
2687
|
pathLocationToFilterInput,
|
|
2611
2688
|
publicSearchHref,
|
|
2612
2689
|
queryListings,
|
|
2690
|
+
rangeDraftFromPath,
|
|
2613
2691
|
readPublicSearch,
|
|
2614
2692
|
reduceAppliedSearchQuery2 as reduceAppliedSearchQuery,
|
|
2615
2693
|
resolvePublicSiteId,
|
|
2694
|
+
searchChromeModel,
|
|
2616
2695
|
searchHrefUsesLegacyFilterQuery,
|
|
2617
2696
|
searchListings,
|
|
2618
2697
|
searchResultsHeading,
|
|
@@ -2627,6 +2706,7 @@ export {
|
|
|
2627
2706
|
studioLeadInstruction,
|
|
2628
2707
|
studioListingDetailInstruction,
|
|
2629
2708
|
studioSdkPinInstruction,
|
|
2709
|
+
studioSearchInstruction,
|
|
2630
2710
|
studioSearchLandmarkInstruction,
|
|
2631
2711
|
studioSiteWidthCss,
|
|
2632
2712
|
submitContactLead,
|