@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/dist/react.js CHANGED
@@ -31,17 +31,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/react/index.ts
32
32
  var react_exports = {};
33
33
  __export(react_exports, {
34
- FilterPanel: () => FilterPanel,
35
34
  ListingCard: () => ListingCard,
36
35
  ListingDetailFields: () => ListingDetailFields,
37
36
  ResultsSkeleton: () => ResultsSkeleton,
38
37
  SearchChromeStyles: () => SearchChromeStyles,
39
- SearchPage: () => SearchPage,
40
- SearchPageFallback: () => SearchPageFallback,
41
- SearchPagination: () => SearchPagination,
42
- SearchQueryForm: () => SearchQueryForm,
43
- SearchSortSelect: () => SearchSortSelect,
44
- rangeDraftFromPath: () => rangeDraftFromPath,
45
38
  usePublicSearch: () => usePublicSearch
46
39
  });
47
40
  module.exports = __toCommonJS(react_exports);
@@ -82,15 +75,6 @@ function formatListingPrice(amount, locale = "pt-BR", currency = "BRL") {
82
75
  return `${currency} ${amount}`;
83
76
  }
84
77
  }
85
- function formatGroupedInteger(value, locale = "pt-BR") {
86
- const digits = String(value ?? "").replace(/\D/g, "");
87
- if (!digits) return "";
88
- const amount = Number.parseInt(digits, 10);
89
- if (!Number.isFinite(amount)) return "";
90
- return new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }).format(
91
- amount
92
- );
93
- }
94
78
  function parseGroupedInteger(value) {
95
79
  if (typeof value === "number") {
96
80
  return Number.isFinite(value) ? Math.trunc(value) : void 0;
@@ -155,8 +139,8 @@ function cn(...parts) {
155
139
  var import_react = require("react");
156
140
 
157
141
  // src/react/styles/search-chrome-css.generated.ts
158
- var SEARCH_CHROME_CSS_VERSION = "0.4.14";
159
- var SEARCH_CHROME_CSS = `:root{--garagem-listing-card-radius:0.75rem;--garagem-listing-card-gap:1.5rem;--garagem-listing-price-size:1.125rem;--garagem-listing-media-ratio:4 / 3;--garagem-search-control-height:2.75rem;--garagem-search-icon-size:1.25rem;--garagem-search-radius:var(--radius,0.75rem);--garagem-skeleton:var(--muted,#e7e5e4)}[data-slot="search-heading"]{display:flex;min-width:0;align-items:baseline;gap:0.375rem;font-size:1.25rem;font-weight:600}[data-slot="search-heading-count"]{flex-shrink:0}[data-slot="search-heading-title"]{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:inherit;font-weight:inherit}[data-slot="search-query-sort"]{display:flex;flex-direction:column;gap:1rem}@media (min-width:1024px){[data-slot="search-query-sort"]{flex-direction:row;align-items:flex-end}}[data-slot="search-query"]{flex:1;min-width:0}[data-slot="search-query-input"],[data-slot="search-sort-trigger"],[data-slot="search-toolbar-trigger"],[data-slot="search-filters-trigger"]{min-height:var(--garagem-search-control-height)}[data-slot="search-query-field"]{position:relative}[data-slot="search-query-input"]{width:100%;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0.5rem 5.5rem 0.5rem 1rem;outline:none}[data-slot="search-query-actions"]{position:absolute;top:50%;right:0.35rem;display:flex;transform:translateY(-50%);align-items:center;gap:0.15rem}[data-slot="search-icon-button"]{display:inline-flex;height:2.25rem;width:2.25rem;cursor:pointer;align-items:center;justify-content:center;border:0;border-radius:999px;background:var(--primary,#111);color:var(--primary-foreground,#fff)}[data-slot="search-icon-button"][data-kind="clear"]{background:transparent;color:var(--muted-foreground,#737373)}[data-slot="search-icon"]{width:var(--garagem-search-icon-size);height:var(--garagem-search-icon-size);display:block}[data-slot="search-sort"]{display:flex;flex-direction:column;gap:0.25rem}[data-slot="search-sort-trigger"]{appearance:none;cursor:pointer;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0.5rem 2.25rem 0.5rem 0.75rem;background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23737373' stroke-width='2' viewBox='0 0 24 24'><path d='m6 9 6 6 6-6'/></svg>");background-repeat:no-repeat;background-position:right 0.65rem center}[data-slot="search-toolbar"]{display:flex;flex-wrap:wrap;align-items:flex-end;gap:0.5rem}[data-slot="search-toolbar-trigger"],[data-slot="search-filters-trigger"]{cursor:pointer;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0.5rem 0.75rem;font-size:0.875rem}[data-slot="search-popover"]{position:absolute;z-index:30;margin-top:0.5rem;width:18rem;border-radius:0.75rem;border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:1rem;box-shadow:0 10px 30px rgb(0 0 0 / 0.12);animation:garagem-search-in 140ms ease-out}[data-slot="search-grid"],[data-slot="search-skeleton"]{display:grid;grid-template-columns:1fr;gap:var(--garagem-listing-card-gap)}@media (min-width:640px){[data-slot="search-grid"],[data-slot="search-skeleton"]{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width:1024px){[data-slot="search-grid"],[data-slot="search-skeleton"]{grid-template-columns:repeat(3,minmax(0,1fr))}}[data-slot="listing-card"]{overflow:hidden;border-radius:var(--garagem-listing-card-radius);border:1px solid var(--border,#e4e4e7);background:var(--card,var(--background,#fff))}[data-slot="listing-card-price-row"]{display:inline-flex;align-items:baseline;gap:0.25rem}[data-slot="listing-card-price"]{font-size:var(--garagem-listing-price-size);font-weight:600}[data-slot="listing-card-period"]{font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="search-checkbox"]{appearance:none;width:1.15rem;height:1.15rem;flex-shrink:0;cursor:pointer;border:1px solid var(--primary,#111);border-radius:0.25rem;background:var(--background,#fff)}[data-slot="search-checkbox"]:checked{background-color:var(--primary,#111);background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'><path d='M5 12l5 5L20 7'/></svg>");background-repeat:no-repeat;background-position:center;background-size:0.8rem}[data-slot="search-scroll"]{max-height:12rem;overflow:auto;scrollbar-width:thin;scrollbar-color:var(--muted-foreground,#a1a1aa) transparent}[data-slot="search-range-apply"]{display:inline-flex;min-height:2.5rem;cursor:pointer;align-items:center;justify-content:center;border:0;border-radius:var(--garagem-search-radius);background:var(--primary,#111);color:var(--primary-foreground,#fff);padding:0 0.75rem;font-size:0.75rem;font-weight:600}[data-slot="search-sheet"]{position:fixed;inset:0;z-index:40}[data-slot="search-sheet-overlay"]{position:absolute;inset:0;border:0;cursor:pointer;background:rgb(0 0 0 / 0.4);animation:garagem-search-fade 160ms ease-out}[data-slot="search-sheet-panel"]{position:absolute;top:0;right:0;display:flex;height:100dvh;width:min(22rem,100%);flex-direction:column;background:var(--background,#fff);animation:garagem-search-sheet 180ms ease-out}[data-slot="search-sheet-body"]{min-height:0;flex:1;overflow:auto;padding:1.5rem 1.5rem 0;scrollbar-width:thin}[data-slot="search-sheet-footer"]{display:flex;gap:0.5rem;border-top:1px solid var(--border,#e4e4e7);padding:1rem 1.5rem}[data-slot="search-apply-bar"]{display:flex;width:100%;gap:0.5rem}[data-slot="search-apply-bar"] > button{min-height:2.5rem;flex:1;cursor:pointer;border-radius:var(--garagem-search-radius);padding:0 1rem}[data-slot="search-apply-bar"] > button[data-kind="clear"]{border:1px solid var(--border,#e4e4e7);background:transparent}[data-slot="search-apply-bar"] > button[data-kind="apply"]{border:0;background:var(--primary,#111);color:var(--primary-foreground,#fff);font-weight:600}[data-slot="search-pagination"]{margin-top:2.5rem;display:flex;justify-content:center}[data-slot="search-pagination"] ul{display:flex;flex-wrap:wrap;justify-content:center;gap:0.25rem;padding:0;margin:0;list-style:none}[data-slot="search-pagination-item"]{display:inline-flex;width:2.25rem;height:2.25rem;align-items:center;justify-content:center;border:1px solid var(--border,#e4e4e7);border-radius:0.375rem;font-size:0.75rem;font-weight:500}@media (min-width:768px){[data-slot="search-pagination-item"]{width:2.5rem;height:2.5rem}}[data-slot="search-pagination-item"] a,[data-slot="search-pagination-item"] span{display:flex;width:100%;height:100%;align-items:center;justify-content:center;color:inherit;text-decoration:none}[data-slot="search-pagination-item"][data-current="true"]{background:var(--primary,#111);color:var(--primary-foreground,#fff)}[data-slot="search-pagination-item"][data-disabled="true"]{cursor:not-allowed;color:var(--muted-foreground,#737373)}[data-slot="search-toolbar-item"]{position:relative}[data-slot="search-body"]{margin-top:2rem;display:flex;flex-direction:column;gap:1.5rem}[data-slot="search-label"]{margin-bottom:0.25rem;display:block;font-size:0.875rem;color:var(--muted-foreground,#737373)}[data-slot="search-sheet-title"]{padding:1.5rem 1.5rem 0;font-size:1.125rem;font-weight:600}[data-slot="search-layout"]{display:grid;gap:2rem}[data-slot="search-sidebar"]{display:none}[data-slot="search-layout"] > div > [data-slot="search-filters-trigger"]{margin-bottom:1rem}@media (min-width:1024px){[data-slot="search-layout"]{grid-template-columns:280px minmax(0,1fr)}[data-slot="search-sidebar"]{display:block;position:sticky;top:1.5rem;align-self:start}[data-slot="search-layout"] > div > [data-slot="search-filters-trigger"]{display:none}}[data-slot="listing-card-link"]{display:block;color:inherit;text-decoration:none;cursor:pointer}[data-slot="listing-card-media"]{position:relative;width:100%;overflow:hidden;background:var(--muted,#f5f5f4);aspect-ratio:var(--garagem-listing-media-ratio)}[data-slot="listing-card-media"] img{height:100%;width:100%;object-fit:cover;transition:transform 0.3s}[data-slot="listing-card"]:hover [data-slot="listing-card-media"] img{transform:scale(1.05)}@media (prefers-reduced-motion:reduce){[data-slot="listing-card-media"] img{transition:none}[data-slot="listing-card"]:hover [data-slot="listing-card-media"] img{transform:none}}[data-slot="listing-card-empty"]{display:flex;height:100%;width:100%;align-items:center;justify-content:center;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="listing-card-cta"]{margin-top:0.75rem}[data-slot="search-filters"]{display:flex;flex-direction:column;gap:1.25rem}[data-slot="search-filter"]{margin:0;padding:0;border:0;font-size:0.875rem}[data-slot="search-filter"] legend{margin-bottom:0.5rem;padding:0;color:var(--muted-foreground,#737373)}[data-slot="search-range-row"]{display:flex;align-items:flex-end;gap:0.5rem}[data-slot="search-range-side"]{min-width:0;flex:1}[data-slot="search-range-side"] > span:first-child{margin-bottom:0.25rem;display:block;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="search-range-affix"]{position:relative;display:block}[data-slot="search-range-prefix"]{pointer-events:none;position:absolute;inset-block:0;left:0;display:flex;align-items:center;padding-left:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="search-range-input"]{min-height:2.5rem;width:100%;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0 0.75rem}[data-slot="search-range-affix"] [data-slot="search-range-input"]{padding-left:2.5rem}[data-slot="search-count-group"]{display:flex;flex-wrap:wrap;gap:0.375rem}[data-slot="search-count-choice"]{min-height:2.5rem;cursor:pointer;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0 0.75rem;font-size:0.875rem}[data-slot="search-count-choice"][data-selected="true"]{border-color:var(--primary,#111);background:color-mix(in srgb,var(--primary,#111) 10%,transparent)}[data-slot="search-enum-list"],[data-slot="search-scroll"]{display:flex;flex-direction:column;gap:0.375rem}[data-slot="search-enum-option"]{display:flex;cursor:pointer;align-items:center;gap:0.5rem}[data-slot="listing-card-badge"]{position:absolute;left:0.75rem;top:0.75rem;border-radius:999px;background:color-mix(in srgb,var(--background,#fff) 90%,transparent);padding:0.25rem 0.5rem;font-size:0.75rem;font-weight:500}[data-slot="listing-card-body"]{padding:1rem}[data-slot="listing-card-title"]{display:-webkit-box;margin-top:0.25rem;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1;font-size:0.875rem;font-weight:500}[data-slot="listing-card-location"]{margin-top:0.125rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="listing-card-features"]{display:flex;flex-wrap:wrap;margin-top:0.75rem;gap:0.25rem 1rem;padding:0;list-style:none;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="search-skeleton-block"]{animation:garagem-search-pulse 1.2s ease-in-out infinite;background:var(--garagem-skeleton);border-radius:0.375rem}[data-slot="search-skeleton-card"]{overflow:hidden;border-radius:var(--garagem-listing-card-radius);border:1px solid var(--border,#e4e4e7)}[data-slot="search-skeleton-body"]{display:flex;flex-direction:column;gap:0.5rem;padding:1rem}[data-slot="search-skeleton-block"][data-kind="media"]{aspect-ratio:var(--garagem-listing-media-ratio)}[data-slot="search-skeleton-block"][data-kind="line-lg"]{height:1.25rem;width:50%}[data-slot="search-skeleton-block"][data-kind="line-md"]{height:1rem;width:75%}[data-slot="search-skeleton-block"][data-kind="line-sm"]{height:0.75rem;width:66.666667%}[data-slot="search-skeleton-block"][data-kind="detail-media"]{max-width:45rem;aspect-ratio:4 / 3}[data-slot="search-skeleton-block"][data-kind="detail-title"]{width:66.666667%;height:2rem;margin-top:1.5rem}@media (prefers-reduced-motion:reduce){[data-slot="search-popover"],[data-slot="search-sheet-overlay"],[data-slot="search-sheet-panel"],[data-slot="search-skeleton-block"]{animation:none}}@keyframes garagem-search-in{from{opacity:0;transform:translateY(-4px) scale(0.98)}to{opacity:1;transform:none}}@keyframes garagem-search-fade{from{opacity:0}to{opacity:1}}@keyframes garagem-search-sheet{from{transform:translateX(100%)}to{transform:none}}@keyframes garagem-search-pulse{50%{opacity:0.55}}`;
142
+ var SEARCH_CHROME_CSS_VERSION = "0.5.1";
143
+ var SEARCH_CHROME_CSS = ':root{--garagem-listing-card-radius:0.75rem;--garagem-listing-card-gap:1.5rem;--garagem-listing-price-size:1.125rem;--garagem-listing-media-ratio:4 / 3;--garagem-skeleton:var(--muted,#e7e5e4)}[data-slot="search-grid"],[data-slot="search-skeleton"]{display:grid;grid-template-columns:1fr;gap:var(--garagem-listing-card-gap)}@media (min-width:640px){[data-slot="search-grid"],[data-slot="search-skeleton"]{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width:1024px){[data-slot="search-grid"],[data-slot="search-skeleton"]{grid-template-columns:repeat(3,minmax(0,1fr))}}[data-slot="listing-card"]{overflow:hidden;border-radius:var(--garagem-listing-card-radius);border:1px solid var(--border,#e4e4e7);background:var(--card,var(--background,#fff))}[data-slot="listing-card-price-row"]{display:inline-flex;align-items:baseline;gap:0.25rem}[data-slot="listing-card-price"]{font-size:var(--garagem-listing-price-size);font-weight:600}[data-slot="listing-card-period"]{font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="listing-card-link"]{display:block;color:inherit;text-decoration:none;cursor:pointer}[data-slot="listing-card-media"]{position:relative;width:100%;overflow:hidden;background:var(--muted,#f5f5f4);aspect-ratio:var(--garagem-listing-media-ratio)}[data-slot="listing-card-media"] img{height:100%;width:100%;object-fit:cover;transition:transform 0.3s}[data-slot="listing-card"]:hover [data-slot="listing-card-media"] img{transform:scale(1.05)}@media (prefers-reduced-motion:reduce){[data-slot="listing-card-media"] img{transition:none}[data-slot="listing-card"]:hover [data-slot="listing-card-media"] img{transform:none}}[data-slot="listing-card-empty"]{display:flex;height:100%;width:100%;align-items:center;justify-content:center;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="listing-card-cta"]{margin-top:0.75rem}[data-slot="listing-card-badge"]{position:absolute;left:0.75rem;top:0.75rem;border-radius:999px;background:color-mix(in srgb,var(--background,#fff) 90%,transparent);padding:0.25rem 0.5rem;font-size:0.75rem;font-weight:500}[data-slot="listing-card-body"]{padding:1rem}[data-slot="listing-card-title"]{display:-webkit-box;margin-top:0.25rem;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1;font-size:0.875rem;font-weight:500}[data-slot="listing-card-location"]{margin-top:0.125rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="listing-card-features"]{display:flex;flex-wrap:wrap;margin-top:0.75rem;gap:0.25rem 1rem;padding:0;list-style:none;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="search-skeleton-block"]{animation:garagem-search-pulse 1.2s ease-in-out infinite;background:var(--garagem-skeleton);border-radius:0.375rem}[data-slot="search-skeleton-card"]{overflow:hidden;border-radius:var(--garagem-listing-card-radius);border:1px solid var(--border,#e4e4e7)}[data-slot="search-skeleton-body"]{display:flex;flex-direction:column;gap:0.5rem;padding:1rem}[data-slot="search-skeleton-block"][data-kind="media"]{aspect-ratio:var(--garagem-listing-media-ratio)}[data-slot="search-skeleton-block"][data-kind="line-lg"]{height:1.25rem;width:50%}[data-slot="search-skeleton-block"][data-kind="line-md"]{height:1rem;width:75%}[data-slot="search-skeleton-block"][data-kind="line-sm"]{height:0.75rem;width:66.666667%}[data-slot="search-skeleton-block"][data-kind="detail-media"]{max-width:45rem;aspect-ratio:4 / 3}[data-slot="search-skeleton-block"][data-kind="detail-title"]{width:66.666667%;height:2rem;margin-top:1.5rem}@media (prefers-reduced-motion:reduce){[data-slot="search-skeleton-block"]{animation:none}}@keyframes garagem-search-pulse{50%{opacity:0.55}}';
160
144
 
161
145
  // src/react/styles/search-chrome-styles.tsx
162
146
  var STYLE_ID = `garagem-search-chrome-${SEARCH_CHROME_CSS_VERSION}`;
@@ -1052,22 +1036,6 @@ var PATH_FILTER_IDS = {
1052
1036
  propertyFeatures: "propertyFeatures",
1053
1037
  buildingAmenities: "buildingAmenities"
1054
1038
  };
1055
- var SEARCH_SORT_RELEVANCE = {
1056
- id: "",
1057
- label: "Mais relevantes"
1058
- };
1059
- function searchSortOptions(sorts) {
1060
- const fromApi = (sorts || []).filter((sort) => sort.id);
1061
- return [
1062
- { id: SEARCH_SORT_RELEVANCE.id, label: SEARCH_SORT_RELEVANCE.label },
1063
- ...fromApi
1064
- ];
1065
- }
1066
- var TOOLBAR_PRIMARY_FILTER_IDS = [
1067
- "price",
1068
- "property_bedrooms"
1069
- ];
1070
- var HIDDEN_FILTER_IDS = /* @__PURE__ */ new Set(["property_suites"]);
1071
1039
  function toFiniteNumber(value) {
1072
1040
  if (value === "" || value == null) return void 0;
1073
1041
  const n = Number(value);
@@ -1177,22 +1145,6 @@ function applyPathFilter(pathFilters, filterId, value) {
1177
1145
  }
1178
1146
  return next;
1179
1147
  }
1180
- function pathFilterValue(pathFilters, filterId) {
1181
- const key = PATH_FILTER_IDS[filterId];
1182
- const value = pathFilters && key ? pathFilters[key] : void 0;
1183
- if (value == null) return "";
1184
- if (Array.isArray(value)) return value[0] != null ? String(value[0]) : "";
1185
- if (typeof value === "object") return "";
1186
- return String(value);
1187
- }
1188
- function pathFilterHasOption(pathFilters, filterId, optionId) {
1189
- const key = PATH_FILTER_IDS[filterId];
1190
- const value = pathFilters && key ? pathFilters[key] : void 0;
1191
- if (value == null) return false;
1192
- if (Array.isArray(value)) return value.map(String).includes(optionId);
1193
- if (typeof value === "object") return false;
1194
- return String(value) === optionId;
1195
- }
1196
1148
  function publicSearchHref(pathFilters, applied, dictionary, existingSearch) {
1197
1149
  const pathname = composeSearchPublicPath2(pathFilters || {}, dictionary);
1198
1150
  return composeSearchPublicHref2(pathname, applied || {}, existingSearch);
@@ -1243,100 +1195,6 @@ function clearStagedPathFilters(current, keepFilterIds = []) {
1243
1195
  }
1244
1196
  return next;
1245
1197
  }
1246
- function visibleSearchFilters(schema) {
1247
- if (!schema?.filters) return [];
1248
- return schema.filters.filter((filter) => {
1249
- if (HIDDEN_FILTER_IDS.has(filter.id)) return false;
1250
- if (filter.id === "listing_type" && (filter.options?.length ?? 0) <= 1) {
1251
- return false;
1252
- }
1253
- return true;
1254
- });
1255
- }
1256
- function toolbarFilterIds(schema) {
1257
- const visible = new Set(visibleSearchFilters(schema).map((f) => f.id));
1258
- return TOOLBAR_PRIMARY_FILTER_IDS.filter((id) => visible.has(id));
1259
- }
1260
- function countOptionLabel(option) {
1261
- const label = String(option?.label ?? "");
1262
- if (/^[1-9]\d*$/.test(label)) return `${label}+`;
1263
- return label;
1264
- }
1265
- function countFacetChoices(options) {
1266
- const list = options || [];
1267
- const zero = list.find((o) => o.id === "0" || o.label === "Studio");
1268
- const isStudio = Boolean(
1269
- zero && /studio/i.test(String(zero.label)) && zero.id === "0"
1270
- );
1271
- const max = isStudio ? 3 : 4;
1272
- const out = [];
1273
- if (zero) out.push({ id: zero.id, label: countOptionLabel(zero) });
1274
- for (let n = 1; n <= max; n += 1) {
1275
- const option = list.find((o) => o.id === String(n));
1276
- out.push({
1277
- id: String(n),
1278
- label: countOptionLabel(option || { label: String(n) })
1279
- });
1280
- }
1281
- return out;
1282
- }
1283
- var FEMININE_HEADING = /(casa|cobertura|kitnet|loja|sala|fazenda|chácara|chacara)s?$/i;
1284
- function pluralizePt(label) {
1285
- const text = label.trim();
1286
- if (!text || /s$/i.test(text)) return text;
1287
- if (/il$/i.test(text)) return `${text.slice(0, -1)}is`;
1288
- if (/m$/i.test(text)) return `${text.slice(0, -1)}ns`;
1289
- return `${text}s`;
1290
- }
1291
- function headingLocationSuffix(location) {
1292
- if (!location) return "";
1293
- if (location.street && location.neighborhood) {
1294
- return `${location.street}, ${location.neighborhood}`;
1295
- }
1296
- if (location.neighborhood && location.city) {
1297
- return `${location.neighborhood}, ${location.city}`;
1298
- }
1299
- if (location.city && location.state) {
1300
- return `${location.city} - ${location.state}`;
1301
- }
1302
- return location.city || location.neighborhood || location.street || location.state || "";
1303
- }
1304
- function searchResultsHeading(pathFilters, dictionary, locationNames) {
1305
- const types = [].concat(pathFilters.propertyType || []).filter(Boolean);
1306
- let noun = "Im\xF3veis";
1307
- let found = "encontrados";
1308
- if (types.length === 1) {
1309
- const id = String(types[0]);
1310
- const option = dictionary?.propertyTypes?.find(
1311
- (entry) => entry.id === id || entry.slug === id
1312
- );
1313
- const label = option?.label;
1314
- if (label) {
1315
- noun = pluralizePt(label.charAt(0).toUpperCase() + label.slice(1));
1316
- if (FEMININE_HEADING.test(id) || FEMININE_HEADING.test(label)) {
1317
- found = "encontradas";
1318
- }
1319
- }
1320
- }
1321
- const place = locationNames ? headingLocationSuffix(
1322
- displayPathLocation(pathFilters.location, locationNames)
1323
- ) : "";
1324
- if (place) return `${noun} ${found} em ${place}`;
1325
- return `${noun} ${found}`;
1326
- }
1327
- function hrefWithExplicitPage(href, page) {
1328
- if (page !== 1 || /(?:\?|&)page=/.test(href)) return href;
1329
- return href.includes("?") ? `${href}&page=1` : `${href}?page=1`;
1330
- }
1331
- function paginationPages(currentPage, totalPages, padding) {
1332
- if (totalPages < 1) return [];
1333
- const current = Math.min(Math.max(1, currentPage), totalPages);
1334
- const start = Math.max(1, current - padding);
1335
- const end = Math.min(totalPages, current + padding);
1336
- const pages = [];
1337
- for (let i = start; i <= end; i += 1) pages.push(i);
1338
- return pages;
1339
- }
1340
1198
 
1341
1199
  // src/listing-detail.ts
1342
1200
  function finiteNumber(value) {
@@ -1535,447 +1393,23 @@ function ListingDetailFields({
1535
1393
  );
1536
1394
  }
1537
1395
 
1538
- // src/react/search-page.tsx
1539
- var import_react3 = require("react");
1540
-
1541
- // src/react/filter-panel.tsx
1542
- var import_jsx_runtime3 = require("react/jsx-runtime");
1543
- function RangeFields({
1544
- filter,
1545
- rangeDraft,
1546
- onRangePatch,
1547
- onRangeCommit
1548
- }) {
1549
- const draft = rangeDraft[filter.id] || { min: "", max: "" };
1550
- const isPrice = filter.id === "price";
1551
- const patch = (side, raw) => {
1552
- onRangePatch(filter.id, side, isPrice ? formatGroupedInteger(raw) : raw);
1553
- };
1554
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("fieldset", { "data-slot": "search-filter", children: [
1555
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("legend", { children: filter.label }),
1556
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-slot": "search-range-row", children: [
1557
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1558
- RangeSide,
1559
- {
1560
- id: `${filter.id}-min`,
1561
- label: "M\xEDn",
1562
- isPrice,
1563
- value: draft.min,
1564
- onPatch: (raw) => patch("min", raw),
1565
- onCommit: () => onRangeCommit(filter.id, "blur"),
1566
- onEnter: () => onRangeCommit(filter.id, "enter")
1567
- }
1568
- ),
1569
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1570
- RangeSide,
1571
- {
1572
- id: `${filter.id}-max`,
1573
- label: "M\xE1x",
1574
- isPrice,
1575
- value: draft.max,
1576
- onPatch: (raw) => patch("max", raw),
1577
- onCommit: () => onRangeCommit(filter.id, "blur"),
1578
- onEnter: () => onRangeCommit(filter.id, "enter")
1579
- }
1580
- ),
1581
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1582
- "button",
1583
- {
1584
- type: "button",
1585
- "data-slot": "search-range-apply",
1586
- onClick: () => onRangeCommit(filter.id, "apply"),
1587
- children: "Atualizar"
1588
- }
1589
- )
1590
- ] })
1591
- ] });
1592
- }
1593
- function RangeSide({
1594
- id,
1595
- label,
1596
- isPrice,
1597
- value,
1598
- onPatch,
1599
- onCommit,
1600
- onEnter
1601
- }) {
1602
- const input = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1603
- "input",
1604
- {
1605
- id,
1606
- type: isPrice ? "text" : "number",
1607
- inputMode: isPrice ? "numeric" : "decimal",
1608
- min: isPrice ? void 0 : 0,
1609
- step: isPrice ? void 0 : 0.01,
1610
- value,
1611
- placeholder: isPrice ? "0" : void 0,
1612
- onChange: (event) => onPatch(event.target.value),
1613
- onBlur: onCommit,
1614
- onKeyDown: (event) => {
1615
- if (event.key === "Enter") {
1616
- event.preventDefault();
1617
- onEnter();
1618
- }
1619
- },
1620
- "data-slot": "search-range-input"
1621
- }
1622
- );
1623
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { "data-slot": "search-range-side", htmlFor: id, children: [
1624
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: label }),
1625
- isPrice ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { "data-slot": "search-range-affix", children: [
1626
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "data-slot": "search-range-prefix", children: "R$" }),
1627
- input
1628
- ] }) : input
1629
- ] });
1630
- }
1631
- function CountFields({
1632
- filter,
1633
- pathFilters,
1634
- onChange
1635
- }) {
1636
- const selected = pathFilterValue(pathFilters, filter.id);
1637
- const choices = countFacetChoices(filter.options);
1638
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("fieldset", { "data-slot": "search-filter", children: [
1639
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("legend", { children: filter.label }),
1640
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-count-group", role: "group", children: choices.map((choice) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1641
- "button",
1642
- {
1643
- type: "button",
1644
- "data-slot": "search-count-choice",
1645
- "data-selected": selected === choice.id ? "true" : void 0,
1646
- onClick: () => onChange(filter.id, Number(choice.id)),
1647
- children: choice.label
1648
- },
1649
- choice.id
1650
- )) })
1651
- ] });
1652
- }
1653
- function EnumFields({
1654
- filter,
1655
- pathFilters,
1656
- onChange
1657
- }) {
1658
- const options = filter.options || [];
1659
- const scroll = options.length > 8;
1660
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("fieldset", { "data-slot": "search-filter", children: [
1661
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("legend", { children: filter.label }),
1662
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": scroll ? "search-scroll" : "search-enum-list", children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { "data-slot": "search-enum-option", children: [
1663
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1664
- "input",
1665
- {
1666
- type: "checkbox",
1667
- "data-slot": "search-checkbox",
1668
- checked: pathFilterHasOption(pathFilters, filter.id, option.id),
1669
- onChange: () => onChange(filter.id, option.id)
1670
- }
1671
- ),
1672
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: option.label })
1673
- ] }, option.id)) })
1674
- ] });
1675
- }
1676
- function FilterPanel({
1677
- filters,
1678
- pathFilters,
1679
- onChange,
1680
- rangeDraft,
1681
- onRangePatch,
1682
- onRangeCommit
1683
- }) {
1684
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-filters", children: filters.map((filter) => {
1685
- if (filter.type === "range") {
1686
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1687
- RangeFields,
1688
- {
1689
- filter,
1690
- rangeDraft,
1691
- onRangePatch,
1692
- onRangeCommit
1693
- },
1694
- filter.id
1695
- );
1696
- }
1697
- if (filter.type === "count") {
1698
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1699
- CountFields,
1700
- {
1701
- filter,
1702
- pathFilters,
1703
- onChange
1704
- },
1705
- filter.id
1706
- );
1707
- }
1708
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1709
- EnumFields,
1710
- {
1711
- filter,
1712
- pathFilters,
1713
- onChange
1714
- },
1715
- filter.id
1716
- );
1717
- }) });
1718
- }
1719
- function rangeDraftFromPath(pathFilters) {
1720
- const price = pathFilters.price || {};
1721
- const area = pathFilters.area || {};
1722
- return {
1723
- price: {
1724
- min: price.min != null ? formatGroupedInteger(price.min) : "",
1725
- max: price.max != null ? formatGroupedInteger(price.max) : ""
1726
- },
1727
- property_area_total: {
1728
- min: area.min != null ? String(area.min) : "",
1729
- max: area.max != null ? String(area.max) : ""
1730
- }
1731
- };
1732
- }
1733
-
1734
1396
  // src/react/search-chrome.tsx
1735
- var import_jsx_runtime4 = require("react/jsx-runtime");
1736
- function SearchSortSelect({
1737
- value,
1738
- onChange,
1739
- sorts,
1740
- className
1741
- }) {
1742
- const options = searchSortOptions(sorts);
1743
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { "data-slot": "search-sort", className, children: [
1744
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-slot": "search-label", children: "Ordenar" }),
1745
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1746
- "select",
1747
- {
1748
- id: "garagem-search-sort",
1749
- "data-slot": "search-sort-trigger",
1750
- value,
1751
- onChange: (event) => onChange(event.target.value || null),
1752
- children: options.map((sort) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: sort.id, children: sort.label }, sort.id || "relevance"))
1753
- }
1754
- )
1755
- ] });
1756
- }
1397
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1757
1398
  function ResultsSkeleton({
1758
1399
  className
1759
1400
  }) {
1760
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1761
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SearchChromeStyles, {}),
1762
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "data-slot": "search-skeleton", className, children: Array.from({ length: 6 }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-slot": "search-skeleton-card", children: [
1763
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "media" }),
1764
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-slot": "search-skeleton-body", children: [
1765
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "line-lg" }),
1766
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "line-md" }),
1767
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "line-sm" })
1401
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1402
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SearchChromeStyles, {}),
1403
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-skeleton", className, children: Array.from({ length: 6 }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-slot": "search-skeleton-card", children: [
1404
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "media" }),
1405
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-slot": "search-skeleton-body", children: [
1406
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "line-lg" }),
1407
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "line-md" }),
1408
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "line-sm" })
1768
1409
  ] })
1769
1410
  ] }, i)) })
1770
1411
  ] });
1771
1412
  }
1772
- function SearchPageFallback({
1773
- className,
1774
- as: Root = "main"
1775
- }) {
1776
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Root, { "data-slot": "search-page", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ResultsSkeleton, { className }) });
1777
- }
1778
-
1779
- // src/react/search-pagination.tsx
1780
- var import_link2 = __toESM(require("next/link"));
1781
- var import_jsx_runtime5 = require("react/jsx-runtime");
1782
- function NavItem({
1783
- href,
1784
- label,
1785
- disabled,
1786
- current,
1787
- onNavigate
1788
- }) {
1789
- if (disabled || !href || current) {
1790
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1791
- "li",
1792
- {
1793
- "data-slot": "search-pagination-item",
1794
- "data-current": current ? "true" : void 0,
1795
- "data-disabled": disabled ? "true" : void 0,
1796
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: label })
1797
- }
1798
- );
1799
- }
1800
- function handleClick(event) {
1801
- if (!onNavigate || !href) return;
1802
- if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0) {
1803
- return;
1804
- }
1805
- event.preventDefault();
1806
- onNavigate(href);
1807
- }
1808
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { "data-slot": "search-pagination-item", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_link2.default, { href, onClick: handleClick, "aria-label": label, children: label }) });
1809
- }
1810
- function SearchPagination({
1811
- page,
1812
- totalPages,
1813
- hrefForPage,
1814
- onNavigate,
1815
- className
1816
- }) {
1817
- if (totalPages <= 1) return null;
1818
- const pages = paginationPages(page, totalPages, 2);
1819
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1820
- "nav",
1821
- {
1822
- "data-slot": "search-pagination",
1823
- className,
1824
- "aria-label": "Pagina\xE7\xE3o",
1825
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("ul", { children: [
1826
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1827
- NavItem,
1828
- {
1829
- href: hrefWithExplicitPage(hrefForPage(1), 1),
1830
- label: "\u2039\u2039",
1831
- disabled: page <= 1,
1832
- onNavigate
1833
- }
1834
- ),
1835
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1836
- NavItem,
1837
- {
1838
- href: hrefWithExplicitPage(
1839
- hrefForPage(Math.max(1, page - 1)),
1840
- Math.max(1, page - 1)
1841
- ),
1842
- label: "\u2039",
1843
- disabled: page <= 1,
1844
- onNavigate
1845
- }
1846
- ),
1847
- pages.map((n) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1848
- NavItem,
1849
- {
1850
- href: hrefWithExplicitPage(hrefForPage(n), n),
1851
- label: String(n),
1852
- current: n === page,
1853
- onNavigate
1854
- },
1855
- n
1856
- )),
1857
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1858
- NavItem,
1859
- {
1860
- href: hrefForPage(Math.min(totalPages, page + 1)),
1861
- label: "\u203A",
1862
- disabled: page >= totalPages,
1863
- onNavigate
1864
- }
1865
- ),
1866
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1867
- NavItem,
1868
- {
1869
- href: hrefForPage(totalPages),
1870
- label: "\u203A\u203A",
1871
- disabled: page >= totalPages,
1872
- onNavigate
1873
- }
1874
- )
1875
- ] })
1876
- }
1877
- );
1878
- }
1879
-
1880
- // src/react/icons.tsx
1881
- var import_jsx_runtime6 = require("react/jsx-runtime");
1882
- function Icon({ children, ...props }) {
1883
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1884
- "svg",
1885
- {
1886
- viewBox: "0 0 24 24",
1887
- fill: "none",
1888
- stroke: "currentColor",
1889
- strokeWidth: 2,
1890
- strokeLinecap: "round",
1891
- strokeLinejoin: "round",
1892
- "aria-hidden": true,
1893
- "data-slot": "search-icon",
1894
- ...props,
1895
- children
1896
- }
1897
- );
1898
- }
1899
- function SearchLensIcon(props) {
1900
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Icon, { ...props, children: [
1901
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("circle", { cx: "11", cy: "11", r: "7" }),
1902
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M20 20l-3.5-3.5" })
1903
- ] });
1904
- }
1905
- function SearchClearIcon(props) {
1906
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M6 6l12 12M18 6L6 18" }) });
1907
- }
1908
-
1909
- // src/react/search-query-form.tsx
1910
- var import_jsx_runtime7 = require("react/jsx-runtime");
1911
- function SearchQueryForm({
1912
- value,
1913
- onChange,
1914
- onSubmit,
1915
- onClear,
1916
- className,
1917
- iconClassName,
1918
- searchIcon,
1919
- clearIcon
1920
- }) {
1921
- function handleSubmit(event) {
1922
- event.preventDefault();
1923
- onSubmit();
1924
- }
1925
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1926
- "form",
1927
- {
1928
- role: "search",
1929
- "data-slot": "search-query",
1930
- onSubmit: handleSubmit,
1931
- className,
1932
- children: [
1933
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: "garagem-search-q", "data-slot": "search-label", children: "Busca" }),
1934
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-slot": "search-query-field", children: [
1935
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1936
- "input",
1937
- {
1938
- id: "garagem-search-q",
1939
- name: "q",
1940
- type: "text",
1941
- inputMode: "search",
1942
- autoComplete: "off",
1943
- enterKeyHint: "search",
1944
- value,
1945
- onChange: (event) => onChange(event.target.value),
1946
- placeholder: "Busque por bairro, rua ou c\xF3digo",
1947
- "data-slot": "search-query-input"
1948
- }
1949
- ),
1950
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-slot": "search-query-actions", children: [
1951
- value ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1952
- "button",
1953
- {
1954
- type: "button",
1955
- title: "Limpar busca",
1956
- "aria-label": "Limpar busca",
1957
- onClick: onClear,
1958
- "data-slot": "search-icon-button",
1959
- "data-kind": "clear",
1960
- children: clearIcon ?? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SearchClearIcon, { className: iconClassName })
1961
- }
1962
- ) : null,
1963
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1964
- "button",
1965
- {
1966
- type: "submit",
1967
- title: "Buscar",
1968
- "aria-label": "Buscar",
1969
- "data-slot": "search-icon-button",
1970
- children: searchIcon ?? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SearchLensIcon, { className: iconClassName })
1971
- }
1972
- )
1973
- ] })
1974
- ] })
1975
- ]
1976
- }
1977
- );
1978
- }
1979
1413
 
1980
1414
  // src/react/use-public-search.ts
1981
1415
  var import_react2 = require("react");
@@ -2305,392 +1739,12 @@ function usePublicSearch(options) {
2305
1739
  locationNames
2306
1740
  };
2307
1741
  }
2308
-
2309
- // src/react/search-page.tsx
2310
- var import_jsx_runtime8 = require("react/jsx-runtime");
2311
- var SEARCH_EMPTY_COPY = "Nenhum im\xF3vel encontrado. Ajuste a busca ou os filtros.";
2312
- function ToolbarPopover({
2313
- id,
2314
- label,
2315
- open,
2316
- onOpenChange,
2317
- triggerClassName,
2318
- popoverClassName,
2319
- children
2320
- }) {
2321
- const rootRef = (0, import_react3.useRef)(null);
2322
- (0, import_react3.useEffect)(() => {
2323
- if (!open) return;
2324
- function onPointer(event) {
2325
- if (!rootRef.current?.contains(event.target)) {
2326
- onOpenChange(null);
2327
- }
2328
- }
2329
- function onKey(event) {
2330
- if (event.key === "Escape") onOpenChange(null);
2331
- }
2332
- document.addEventListener("mousedown", onPointer);
2333
- document.addEventListener("keydown", onKey);
2334
- return () => {
2335
- document.removeEventListener("mousedown", onPointer);
2336
- document.removeEventListener("keydown", onKey);
2337
- };
2338
- }, [open, onOpenChange]);
2339
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-toolbar-item", ref: rootRef, children: [
2340
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2341
- "button",
2342
- {
2343
- type: "button",
2344
- "data-slot": "search-toolbar-trigger",
2345
- className: triggerClassName,
2346
- "aria-expanded": open,
2347
- onClick: () => onOpenChange(open ? null : id),
2348
- children: label
2349
- }
2350
- ),
2351
- open ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2352
- "div",
2353
- {
2354
- "data-slot": "search-popover",
2355
- className: popoverClassName,
2356
- role: "dialog",
2357
- children
2358
- }
2359
- ) : null
2360
- ] });
2361
- }
2362
- function FiltersTrigger({
2363
- onClick,
2364
- className
2365
- }) {
2366
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2367
- "button",
2368
- {
2369
- type: "button",
2370
- title: "Filtros",
2371
- "data-slot": "search-filters-trigger",
2372
- onClick,
2373
- className,
2374
- children: "Filtros"
2375
- }
2376
- );
2377
- }
2378
- function ApplyBar({
2379
- onClear,
2380
- onApply,
2381
- className
2382
- }) {
2383
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-apply-bar", className, children: [
2384
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "data-kind": "clear", onClick: onClear, children: "Limpar" }),
2385
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "data-kind": "apply", onClick: onApply, children: "Ver resultados" })
2386
- ] });
2387
- }
2388
- function FilterSheet({
2389
- open,
2390
- title,
2391
- onClose,
2392
- overlayClassName,
2393
- panelClassName,
2394
- children,
2395
- footer
2396
- }) {
2397
- const onCloseRef = (0, import_react3.useRef)(onClose);
2398
- onCloseRef.current = onClose;
2399
- (0, import_react3.useEffect)(() => {
2400
- if (!open) return;
2401
- function onKey(event) {
2402
- if (event.key === "Escape") onCloseRef.current();
2403
- }
2404
- document.addEventListener("keydown", onKey);
2405
- const previous = document.body.style.overflow;
2406
- document.body.style.overflow = "hidden";
2407
- return () => {
2408
- document.removeEventListener("keydown", onKey);
2409
- document.body.style.overflow = previous;
2410
- };
2411
- }, [open]);
2412
- if (!open) return null;
2413
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-sheet", children: [
2414
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2415
- "button",
2416
- {
2417
- type: "button",
2418
- "aria-label": "Fechar filtros",
2419
- "data-slot": "search-sheet-overlay",
2420
- className: overlayClassName,
2421
- onClick: onClose
2422
- }
2423
- ),
2424
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
2425
- "div",
2426
- {
2427
- "data-slot": "search-sheet-panel",
2428
- className: panelClassName,
2429
- role: "dialog",
2430
- "aria-modal": "true",
2431
- "aria-label": title,
2432
- children: [
2433
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { "data-slot": "search-sheet-title", children: title }),
2434
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "data-slot": "search-sheet-body", children }),
2435
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "data-slot": "search-sheet-footer", children: footer })
2436
- ]
2437
- }
2438
- )
2439
- ] });
2440
- }
2441
- function SearchHeading({
2442
- total,
2443
- title,
2444
- classNames,
2445
- loading
2446
- }) {
2447
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-heading", className: classNames?.heading, children: [
2448
- !loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2449
- "span",
2450
- {
2451
- "data-slot": "search-heading-count",
2452
- className: classNames?.headingCount,
2453
- children: total.toLocaleString("pt-BR")
2454
- }
2455
- ) : null,
2456
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h1", { "data-slot": "search-heading-title", className: classNames?.headingTitle, children: title })
2457
- ] });
2458
- }
2459
- function SearchPage({
2460
- siteId,
2461
- baseUrl,
2462
- variant = "toolbar",
2463
- as: Root = "main",
2464
- className,
2465
- classNames,
2466
- heading,
2467
- icons,
2468
- listingCard: Card = ListingCard
2469
- }) {
2470
- const search = usePublicSearch({ siteId, baseUrl });
2471
- const [sheetOpen, setSheetOpen] = (0, import_react3.useState)(false);
2472
- const [openToolbar, setOpenToolbar] = (0, import_react3.useState)(null);
2473
- const [rangeDraft, setRangeDraft] = (0, import_react3.useState)(
2474
- () => rangeDraftFromPath(search.pathFilters)
2475
- );
2476
- (0, import_react3.useEffect)(() => {
2477
- setRangeDraft(rangeDraftFromPath(search.pathFilters));
2478
- }, [search.pathFilters]);
2479
- const filters = visibleSearchFilters(search.schema);
2480
- const toolbarIds = new Set(toolbarFilterIds(search.schema));
2481
- const toolbarFilters = filters.filter((filter) => toolbarIds.has(filter.id));
2482
- const extraFilters = filters.filter((filter) => !toolbarIds.has(filter.id));
2483
- const headingTitle = searchResultsHeading(
2484
- search.pathFilters,
2485
- search.schema?.dictionary,
2486
- search.locationNames
2487
- );
2488
- function patchRange(filterId, side, value) {
2489
- setRangeDraft((prev) => ({
2490
- ...prev,
2491
- [filterId]: {
2492
- min: prev[filterId]?.min ?? "",
2493
- max: prev[filterId]?.max ?? "",
2494
- [side]: value
2495
- }
2496
- }));
2497
- }
2498
- function commitRange(filterId, immediate) {
2499
- const draft = rangeDraft[filterId] || { min: "", max: "" };
2500
- if (immediate) search.applyFilter(filterId, draft);
2501
- else search.stageFilter(filterId, draft);
2502
- }
2503
- function openStagedFilters() {
2504
- search.resetStagedFromUrl();
2505
- setRangeDraft(rangeDraftFromPath(search.pathFilters));
2506
- setOpenToolbar(null);
2507
- setSheetOpen(true);
2508
- }
2509
- const closeSheet = (0, import_react3.useCallback)(() => {
2510
- setSheetOpen(false);
2511
- }, []);
2512
- function clearStagedFilters() {
2513
- const keepIds = variant === "toolbar" ? [...toolbarIds] : [];
2514
- const source = variant === "toolbar" ? search.pathFilters : search.staged;
2515
- const next = clearStagedPathFilters(source, keepIds);
2516
- search.setStaged(next);
2517
- setRangeDraft((prev) => {
2518
- const cleared = rangeDraftFromPath(next);
2519
- if (variant !== "toolbar") return cleared;
2520
- const kept = { ...cleared };
2521
- for (const id of keepIds) {
2522
- if (prev[id]) kept[id] = prev[id];
2523
- }
2524
- return kept;
2525
- });
2526
- }
2527
- function applyStagedAndClose() {
2528
- search.applyStaged();
2529
- closeSheet();
2530
- }
2531
- const results = search.loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ResultsSkeleton, { className: classNames?.skeleton ?? classNames?.grid }) : search.listings.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { "data-slot": "search-empty", className: classNames?.empty, children: SEARCH_EMPTY_COPY }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
2532
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "data-slot": "search-grid", className: classNames?.grid, children: search.listings.map((listing) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2533
- Card,
2534
- {
2535
- listing,
2536
- className: classNames?.card
2537
- },
2538
- listing.id
2539
- )) }),
2540
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2541
- SearchPagination,
2542
- {
2543
- page: search.page,
2544
- totalPages: search.totalPages,
2545
- hrefForPage: search.hrefForPage,
2546
- onNavigate: search.go,
2547
- className: classNames?.pagination
2548
- }
2549
- )
2550
- ] });
2551
- const queryAndSort = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-query-sort", children: [
2552
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2553
- SearchQueryForm,
2554
- {
2555
- value: search.qDraft,
2556
- onChange: search.setQDraft,
2557
- onSubmit: search.submitQuery,
2558
- onClear: search.clearQuery,
2559
- className: classNames?.query,
2560
- iconClassName: classNames?.icon,
2561
- searchIcon: icons?.search,
2562
- clearIcon: icons?.clear
2563
- }
2564
- ),
2565
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2566
- SearchSortSelect,
2567
- {
2568
- value: search.applied.sort || "",
2569
- onChange: search.setSort,
2570
- sorts: search.schema?.sorts,
2571
- className: classNames?.sort
2572
- }
2573
- )
2574
- ] });
2575
- const header = heading ?? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2576
- SearchHeading,
2577
- {
2578
- total: search.total,
2579
- title: headingTitle,
2580
- classNames,
2581
- loading: search.loading
2582
- }
2583
- );
2584
- const stagedPanel = (items) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2585
- FilterPanel,
2586
- {
2587
- filters: items,
2588
- pathFilters: search.staged,
2589
- onChange: search.stageFilter,
2590
- rangeDraft,
2591
- onRangePatch: patchRange,
2592
- onRangeCommit: (id) => commitRange(id, false)
2593
- }
2594
- );
2595
- const sheet = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2596
- FilterSheet,
2597
- {
2598
- open: sheetOpen,
2599
- title: "Filtros",
2600
- onClose: closeSheet,
2601
- overlayClassName: classNames?.dialogOverlay,
2602
- panelClassName: cn(classNames?.dialog, classNames?.dialogPanel),
2603
- footer: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2604
- ApplyBar,
2605
- {
2606
- onClear: clearStagedFilters,
2607
- onApply: applyStagedAndClose,
2608
- className: classNames?.applyBar
2609
- }
2610
- ),
2611
- children: stagedPanel(variant === "toolbar" ? extraFilters : filters)
2612
- }
2613
- );
2614
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
2615
- Root,
2616
- {
2617
- "data-slot": "search-page",
2618
- "data-variant": variant,
2619
- className: cn(className, classNames?.root),
2620
- children: [
2621
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SearchChromeStyles, {}),
2622
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: classNames?.header, children: header }),
2623
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-body", children: [
2624
- queryAndSort,
2625
- variant === "toolbar" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-toolbar", className: classNames?.toolbar, children: [
2626
- toolbarFilters.map((filter) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2627
- ToolbarPopover,
2628
- {
2629
- id: filter.id,
2630
- label: filter.label,
2631
- open: openToolbar === filter.id,
2632
- onOpenChange: setOpenToolbar,
2633
- triggerClassName: classNames?.toolbarTrigger,
2634
- popoverClassName: classNames?.popover,
2635
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2636
- FilterPanel,
2637
- {
2638
- filters: [filter],
2639
- pathFilters: search.pathFilters,
2640
- onChange: (id, value) => {
2641
- search.applyFilter(id, value);
2642
- if (filter.type !== "range") setOpenToolbar(null);
2643
- },
2644
- rangeDraft,
2645
- onRangePatch: patchRange,
2646
- onRangeCommit: (id, source) => {
2647
- commitRange(id, true);
2648
- if (source === "apply") setOpenToolbar(null);
2649
- }
2650
- }
2651
- )
2652
- },
2653
- filter.id
2654
- )),
2655
- extraFilters.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FiltersTrigger, { onClick: openStagedFilters }) : null
2656
- ] }) : null,
2657
- variant === "dialog" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FiltersTrigger, { onClick: openStagedFilters }) : null,
2658
- variant === "sidebar" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-layout", children: [
2659
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("aside", { "data-slot": "search-sidebar", className: classNames?.sidebar, children: [
2660
- stagedPanel(filters),
2661
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2662
- ApplyBar,
2663
- {
2664
- onClear: clearStagedFilters,
2665
- onApply: search.applyStaged,
2666
- className: classNames?.applyBar
2667
- }
2668
- )
2669
- ] }),
2670
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
2671
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FiltersTrigger, { onClick: openStagedFilters }),
2672
- results
2673
- ] })
2674
- ] }) : results
2675
- ] }),
2676
- sheet
2677
- ]
2678
- }
2679
- );
2680
- }
2681
1742
  // Annotate the CommonJS export names for ESM import in node:
2682
1743
  0 && (module.exports = {
2683
- FilterPanel,
2684
1744
  ListingCard,
2685
1745
  ListingDetailFields,
2686
1746
  ResultsSkeleton,
2687
1747
  SearchChromeStyles,
2688
- SearchPage,
2689
- SearchPageFallback,
2690
- SearchPagination,
2691
- SearchQueryForm,
2692
- SearchSortSelect,
2693
- rangeDraftFromPath,
2694
1748
  usePublicSearch
2695
1749
  });
2696
1750
  //# sourceMappingURL=react.js.map