@garagem-ai/site-sdk 0.4.0 → 0.4.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 +41 -8
- package/dist/index.d.mts +7 -58
- package/dist/index.d.ts +7 -58
- package/dist/index.js +59 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +33 -6
- package/dist/react.d.ts +33 -6
- package/dist/react.js +517 -463
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +515 -462
- package/dist/react.mjs.map +1 -1
- package/dist/{listing-card-model-D7iR4asd.d.mts → search-engine-D4EZkNrQ.d.mts} +67 -1
- package/dist/{listing-card-model-D7iR4asd.d.ts → search-engine-D4EZkNrQ.d.ts} +67 -1
- package/package.json +9 -4
- package/src/index.ts +2 -0
- package/src/presentation.ts +7 -0
- package/src/react/filter-panel.tsx +39 -42
- package/src/react/icons.tsx +46 -0
- package/src/react/index.ts +7 -1
- package/src/react/listing-card.tsx +14 -71
- package/src/react/search-chrome.tsx +24 -23
- package/src/react/search-page.tsx +210 -111
- package/src/react/search-pagination.tsx +50 -40
- package/src/react/search-query-form.tsx +31 -26
- package/src/react/search.css +717 -0
- package/src/react/styles/index.ts +1 -0
- package/src/react/styles/search-chrome-css.generated.ts +5 -0
- package/src/react/styles/search-chrome-styles.tsx +12 -0
- package/src/react/types.ts +18 -0
- package/src/react/use-public-search.ts +7 -0
- package/src/search-engine.ts +79 -0
package/dist/index.mjs
CHANGED
|
@@ -319,13 +319,19 @@ var SEARCH_CSS_VARS = {
|
|
|
319
319
|
cardRadius: "--garagem-listing-card-radius",
|
|
320
320
|
cardGap: "--garagem-listing-card-gap",
|
|
321
321
|
priceSize: "--garagem-listing-price-size",
|
|
322
|
-
mediaRatio: "--garagem-listing-media-ratio"
|
|
322
|
+
mediaRatio: "--garagem-listing-media-ratio",
|
|
323
|
+
controlHeight: "--garagem-search-control-height",
|
|
324
|
+
iconSize: "--garagem-search-icon-size",
|
|
325
|
+
skeleton: "--garagem-skeleton"
|
|
323
326
|
};
|
|
324
327
|
var SEARCH_CSS_RECIPE = `:root {
|
|
325
328
|
${SEARCH_CSS_VARS.cardRadius}: 0.75rem;
|
|
326
329
|
${SEARCH_CSS_VARS.cardGap}: 1.5rem;
|
|
327
330
|
${SEARCH_CSS_VARS.priceSize}: 1.125rem;
|
|
328
331
|
${SEARCH_CSS_VARS.mediaRatio}: 4 / 3;
|
|
332
|
+
${SEARCH_CSS_VARS.controlHeight}: 2.75rem;
|
|
333
|
+
${SEARCH_CSS_VARS.iconSize}: 1.25rem;
|
|
334
|
+
${SEARCH_CSS_VARS.skeleton}: var(--muted, #e7e5e4);
|
|
329
335
|
}
|
|
330
336
|
`;
|
|
331
337
|
function formatListingPrice(amount, locale = "pt-BR", currency = "BRL") {
|
|
@@ -1103,6 +1109,54 @@ function countFacetChoices(options) {
|
|
|
1103
1109
|
}
|
|
1104
1110
|
return out;
|
|
1105
1111
|
}
|
|
1112
|
+
var FEMININE_HEADING = /(casa|cobertura|kitnet|loja|sala|fazenda|chácara|chacara)s?$/i;
|
|
1113
|
+
function pluralizePt(label) {
|
|
1114
|
+
const text = label.trim();
|
|
1115
|
+
if (!text || /s$/i.test(text)) return text;
|
|
1116
|
+
if (/il$/i.test(text)) return `${text.slice(0, -1)}is`;
|
|
1117
|
+
if (/m$/i.test(text)) return `${text.slice(0, -1)}ns`;
|
|
1118
|
+
return `${text}s`;
|
|
1119
|
+
}
|
|
1120
|
+
function headingLocationSuffix(location) {
|
|
1121
|
+
if (!location) return "";
|
|
1122
|
+
if (location.street && location.neighborhood) {
|
|
1123
|
+
return `${location.street}, ${location.neighborhood}`;
|
|
1124
|
+
}
|
|
1125
|
+
if (location.neighborhood && location.city) {
|
|
1126
|
+
return `${location.neighborhood}, ${location.city}`;
|
|
1127
|
+
}
|
|
1128
|
+
if (location.city && location.state) {
|
|
1129
|
+
return `${location.city} - ${location.state}`;
|
|
1130
|
+
}
|
|
1131
|
+
return location.city || location.neighborhood || location.street || location.state || "";
|
|
1132
|
+
}
|
|
1133
|
+
function searchResultsHeading(pathFilters, dictionary, locationNames) {
|
|
1134
|
+
const types = [].concat(pathFilters.propertyType || []).filter(Boolean);
|
|
1135
|
+
let noun = "Im\xF3veis";
|
|
1136
|
+
let found = "encontrados";
|
|
1137
|
+
if (types.length === 1) {
|
|
1138
|
+
const id = String(types[0]);
|
|
1139
|
+
const option = dictionary?.propertyTypes?.find(
|
|
1140
|
+
(entry) => entry.id === id || entry.slug === id
|
|
1141
|
+
);
|
|
1142
|
+
const label = option?.label;
|
|
1143
|
+
if (label) {
|
|
1144
|
+
noun = pluralizePt(label.charAt(0).toUpperCase() + label.slice(1));
|
|
1145
|
+
if (FEMININE_HEADING.test(id) || FEMININE_HEADING.test(label)) {
|
|
1146
|
+
found = "encontradas";
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
const place = locationNames ? headingLocationSuffix(
|
|
1151
|
+
displayPathLocation(pathFilters.location, locationNames)
|
|
1152
|
+
) : "";
|
|
1153
|
+
if (place) return `${noun} ${found} em ${place}`;
|
|
1154
|
+
return `${noun} ${found}`;
|
|
1155
|
+
}
|
|
1156
|
+
function hrefWithExplicitPage(href, page) {
|
|
1157
|
+
if (page !== 1 || /(?:\?|&)page=/.test(href)) return href;
|
|
1158
|
+
return href.includes("?") ? `${href}&page=1` : `${href}?page=1`;
|
|
1159
|
+
}
|
|
1106
1160
|
function paginationPages(currentPage, totalPages, padding) {
|
|
1107
1161
|
if (totalPages < 1) return [];
|
|
1108
1162
|
const current = Math.min(Math.max(1, currentPage), totalPages);
|
|
@@ -1307,6 +1361,7 @@ export {
|
|
|
1307
1361
|
getSite,
|
|
1308
1362
|
hrefForAppliedChange,
|
|
1309
1363
|
hrefForPathFilters,
|
|
1364
|
+
hrefWithExplicitPage,
|
|
1310
1365
|
isListingDetailPath,
|
|
1311
1366
|
isStudioPreviewHost,
|
|
1312
1367
|
listingBusinessLabel,
|
|
@@ -1329,6 +1384,7 @@ export {
|
|
|
1329
1384
|
resolvePublicSiteId,
|
|
1330
1385
|
searchHrefUsesLegacyFilterQuery,
|
|
1331
1386
|
searchListings,
|
|
1387
|
+
searchResultsHeading,
|
|
1332
1388
|
searchSortOptions,
|
|
1333
1389
|
serializeAppliedSearchQuery2 as serializeAppliedSearchQuery,
|
|
1334
1390
|
toListingCardModel,
|