@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/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,