@garagem-ai/site-sdk 0.4.0 → 0.4.2
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 -9
- package/dist/index.d.mts +57 -58
- package/dist/index.d.ts +57 -58
- package/dist/index.js +187 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +176 -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 +573 -486
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +542 -456
- 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 +15 -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 +61 -106
- package/src/react/search-chrome.tsx +30 -27
- 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 +31 -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/src/studio-contract.ts +138 -0
package/dist/react.js
CHANGED
|
@@ -34,7 +34,9 @@ __export(react_exports, {
|
|
|
34
34
|
FilterPanel: () => FilterPanel,
|
|
35
35
|
ListingCard: () => ListingCard,
|
|
36
36
|
ResultsSkeleton: () => ResultsSkeleton,
|
|
37
|
+
SearchChromeStyles: () => SearchChromeStyles,
|
|
37
38
|
SearchPage: () => SearchPage,
|
|
39
|
+
SearchPageFallback: () => SearchPageFallback,
|
|
38
40
|
SearchPagination: () => SearchPagination,
|
|
39
41
|
SearchQueryForm: () => SearchQueryForm,
|
|
40
42
|
SearchSortSelect: () => SearchSortSelect,
|
|
@@ -51,13 +53,19 @@ var SEARCH_CSS_VARS = {
|
|
|
51
53
|
cardRadius: "--garagem-listing-card-radius",
|
|
52
54
|
cardGap: "--garagem-listing-card-gap",
|
|
53
55
|
priceSize: "--garagem-listing-price-size",
|
|
54
|
-
mediaRatio: "--garagem-listing-media-ratio"
|
|
56
|
+
mediaRatio: "--garagem-listing-media-ratio",
|
|
57
|
+
controlHeight: "--garagem-search-control-height",
|
|
58
|
+
iconSize: "--garagem-search-icon-size",
|
|
59
|
+
skeleton: "--garagem-skeleton"
|
|
55
60
|
};
|
|
56
61
|
var SEARCH_CSS_RECIPE = `:root {
|
|
57
62
|
${SEARCH_CSS_VARS.cardRadius}: 0.75rem;
|
|
58
63
|
${SEARCH_CSS_VARS.cardGap}: 1.5rem;
|
|
59
64
|
${SEARCH_CSS_VARS.priceSize}: 1.125rem;
|
|
60
65
|
${SEARCH_CSS_VARS.mediaRatio}: 4 / 3;
|
|
66
|
+
${SEARCH_CSS_VARS.controlHeight}: 2.75rem;
|
|
67
|
+
${SEARCH_CSS_VARS.iconSize}: 1.25rem;
|
|
68
|
+
${SEARCH_CSS_VARS.skeleton}: var(--muted, #e7e5e4);
|
|
61
69
|
}
|
|
62
70
|
`;
|
|
63
71
|
function formatListingPrice(amount, locale = "pt-BR", currency = "BRL") {
|
|
@@ -142,6 +150,33 @@ function cn(...parts) {
|
|
|
142
150
|
return parts.filter(Boolean).join(" ");
|
|
143
151
|
}
|
|
144
152
|
|
|
153
|
+
// src/react/styles/search-chrome-styles.tsx
|
|
154
|
+
var import_react = require("react");
|
|
155
|
+
|
|
156
|
+
// src/react/styles/search-chrome-css.generated.ts
|
|
157
|
+
var SEARCH_CHROME_CSS_VERSION = "0.4.2";
|
|
158
|
+
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-page"]{margin-inline:auto;max-width:80rem;padding:3rem 1.5rem}[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}}`;
|
|
159
|
+
|
|
160
|
+
// src/react/styles/search-chrome-styles.tsx
|
|
161
|
+
var STYLE_ID = `garagem-search-chrome-${SEARCH_CHROME_CSS_VERSION}`;
|
|
162
|
+
function injectSearchChromeOnce() {
|
|
163
|
+
if (typeof document === "undefined") return;
|
|
164
|
+
if (document.getElementById(STYLE_ID)) return;
|
|
165
|
+
const el = document.createElement("style");
|
|
166
|
+
el.id = STYLE_ID;
|
|
167
|
+
el.textContent = SEARCH_CHROME_CSS;
|
|
168
|
+
document.head.appendChild(el);
|
|
169
|
+
}
|
|
170
|
+
function SearchChromeStyles() {
|
|
171
|
+
if (typeof document !== "undefined") {
|
|
172
|
+
injectSearchChromeOnce();
|
|
173
|
+
}
|
|
174
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
175
|
+
injectSearchChromeOnce();
|
|
176
|
+
}, []);
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
|
|
145
180
|
// src/react/listing-card.tsx
|
|
146
181
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
147
182
|
function isListing(value) {
|
|
@@ -158,142 +193,72 @@ function ListingCard({
|
|
|
158
193
|
const model = isListing(listing) ? toListingCardModel(listing) : listing;
|
|
159
194
|
const target = href ?? model.href;
|
|
160
195
|
const areaLabel = formatAreaM2(model.areaM2);
|
|
161
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
"
|
|
165
|
-
|
|
166
|
-
"
|
|
167
|
-
className,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
href: target,
|
|
175
|
-
className: "block cursor-pointer",
|
|
176
|
-
"data-slot": "listing-card-link",
|
|
177
|
-
children: [
|
|
178
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
179
|
-
"div",
|
|
196
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
197
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SearchChromeStyles, {}),
|
|
198
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
199
|
+
"article",
|
|
200
|
+
{
|
|
201
|
+
"data-slot": "listing-card",
|
|
202
|
+
className: cn(className, classNames?.root),
|
|
203
|
+
style,
|
|
204
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_link.default, { href: target, "data-slot": "listing-card-link", children: [
|
|
205
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { "data-slot": "listing-card-media", className: classNames?.media, children: [
|
|
206
|
+
slots?.media ?? (model.coverSrc ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: model.coverSrc, alt: model.coverAlt }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-slot": "listing-card-empty", children: "Sem foto" })),
|
|
207
|
+
slots?.badge ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
208
|
+
"span",
|
|
180
209
|
{
|
|
181
|
-
"data-slot": "listing-card-
|
|
182
|
-
className:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
"data-slot": "listing-card-badge",
|
|
200
|
-
className: cn(
|
|
201
|
-
"absolute left-3 top-3 rounded-full bg-background/90 px-2 py-1 text-xs font-medium",
|
|
202
|
-
classNames?.badge
|
|
203
|
-
),
|
|
204
|
-
children: model.businessLabel
|
|
205
|
-
}
|
|
206
|
-
)
|
|
207
|
-
]
|
|
210
|
+
"data-slot": "listing-card-badge",
|
|
211
|
+
className: classNames?.badge,
|
|
212
|
+
children: model.businessLabel
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
] }),
|
|
216
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { "data-slot": "listing-card-body", className: classNames?.body, children: [
|
|
217
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { "data-slot": "listing-card-price-row", children: [
|
|
218
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { "data-slot": "listing-card-price", className: classNames?.price, children: model.priceLabel }),
|
|
219
|
+
model.pricePeriod ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "data-slot": "listing-card-period", children: model.pricePeriod }) : null
|
|
220
|
+
] }),
|
|
221
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { "data-slot": "listing-card-title", className: classNames?.title, children: model.title }),
|
|
222
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
223
|
+
"p",
|
|
224
|
+
{
|
|
225
|
+
"data-slot": "listing-card-location",
|
|
226
|
+
className: classNames?.location,
|
|
227
|
+
children: model.locationLabel || model.propertyType || ""
|
|
208
228
|
}
|
|
209
229
|
),
|
|
210
230
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
211
|
-
"
|
|
231
|
+
"ul",
|
|
212
232
|
{
|
|
213
|
-
"data-slot": "listing-card-
|
|
214
|
-
className:
|
|
233
|
+
"data-slot": "listing-card-features",
|
|
234
|
+
className: classNames?.features,
|
|
215
235
|
children: [
|
|
216
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
] }),
|
|
230
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
231
|
-
"h3",
|
|
232
|
-
{
|
|
233
|
-
"data-slot": "listing-card-title",
|
|
234
|
-
className: cn(
|
|
235
|
-
"mt-1 line-clamp-1 text-sm font-medium",
|
|
236
|
-
classNames?.title
|
|
237
|
-
),
|
|
238
|
-
children: model.title
|
|
239
|
-
}
|
|
240
|
-
),
|
|
241
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
242
|
-
"p",
|
|
243
|
-
{
|
|
244
|
-
"data-slot": "listing-card-location",
|
|
245
|
-
className: cn(
|
|
246
|
-
"mt-0.5 line-clamp-1 text-xs text-muted-foreground",
|
|
247
|
-
classNames?.location
|
|
248
|
-
),
|
|
249
|
-
children: model.locationLabel || model.propertyType || ""
|
|
250
|
-
}
|
|
251
|
-
),
|
|
252
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
253
|
-
"ul",
|
|
254
|
-
{
|
|
255
|
-
"data-slot": "listing-card-features",
|
|
256
|
-
className: cn(
|
|
257
|
-
"mt-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",
|
|
258
|
-
classNames?.features
|
|
259
|
-
),
|
|
260
|
-
children: [
|
|
261
|
-
model.bedrooms != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
262
|
-
model.bedrooms,
|
|
263
|
-
" quartos"
|
|
264
|
-
] }) : null,
|
|
265
|
-
model.bathrooms != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
266
|
-
model.bathrooms,
|
|
267
|
-
" banheiros"
|
|
268
|
-
] }) : null,
|
|
269
|
-
model.parkingSpaces != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
270
|
-
model.parkingSpaces,
|
|
271
|
-
" vagas"
|
|
272
|
-
] }) : null,
|
|
273
|
-
areaLabel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: areaLabel }) : null
|
|
274
|
-
]
|
|
275
|
-
}
|
|
276
|
-
),
|
|
277
|
-
slots?.cta ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
278
|
-
"div",
|
|
279
|
-
{
|
|
280
|
-
"data-slot": "listing-card-cta",
|
|
281
|
-
className: cn("mt-3", classNames?.cta),
|
|
282
|
-
children: slots.cta
|
|
283
|
-
}
|
|
284
|
-
) : null
|
|
236
|
+
model.bedrooms != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
237
|
+
model.bedrooms,
|
|
238
|
+
" quartos"
|
|
239
|
+
] }) : null,
|
|
240
|
+
model.bathrooms != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
241
|
+
model.bathrooms,
|
|
242
|
+
" banheiros"
|
|
243
|
+
] }) : null,
|
|
244
|
+
model.parkingSpaces != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
245
|
+
model.parkingSpaces,
|
|
246
|
+
" vagas"
|
|
247
|
+
] }) : null,
|
|
248
|
+
areaLabel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: areaLabel }) : null
|
|
285
249
|
]
|
|
286
250
|
}
|
|
287
|
-
)
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
251
|
+
),
|
|
252
|
+
slots?.cta ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-slot": "listing-card-cta", className: classNames?.cta, children: slots.cta }) : null
|
|
253
|
+
] })
|
|
254
|
+
] })
|
|
255
|
+
}
|
|
256
|
+
)
|
|
257
|
+
] });
|
|
293
258
|
}
|
|
294
259
|
|
|
295
260
|
// src/react/search-page.tsx
|
|
296
|
-
var
|
|
261
|
+
var import_react3 = require("react");
|
|
297
262
|
|
|
298
263
|
// ../search-url/types.ts
|
|
299
264
|
var SEARCH_BASE_ROUTE = "imoveis";
|
|
@@ -981,6 +946,54 @@ function countFacetChoices(options) {
|
|
|
981
946
|
}
|
|
982
947
|
return out;
|
|
983
948
|
}
|
|
949
|
+
var FEMININE_HEADING = /(casa|cobertura|kitnet|loja|sala|fazenda|chácara|chacara)s?$/i;
|
|
950
|
+
function pluralizePt(label) {
|
|
951
|
+
const text = label.trim();
|
|
952
|
+
if (!text || /s$/i.test(text)) return text;
|
|
953
|
+
if (/il$/i.test(text)) return `${text.slice(0, -1)}is`;
|
|
954
|
+
if (/m$/i.test(text)) return `${text.slice(0, -1)}ns`;
|
|
955
|
+
return `${text}s`;
|
|
956
|
+
}
|
|
957
|
+
function headingLocationSuffix(location) {
|
|
958
|
+
if (!location) return "";
|
|
959
|
+
if (location.street && location.neighborhood) {
|
|
960
|
+
return `${location.street}, ${location.neighborhood}`;
|
|
961
|
+
}
|
|
962
|
+
if (location.neighborhood && location.city) {
|
|
963
|
+
return `${location.neighborhood}, ${location.city}`;
|
|
964
|
+
}
|
|
965
|
+
if (location.city && location.state) {
|
|
966
|
+
return `${location.city} - ${location.state}`;
|
|
967
|
+
}
|
|
968
|
+
return location.city || location.neighborhood || location.street || location.state || "";
|
|
969
|
+
}
|
|
970
|
+
function searchResultsHeading(pathFilters, dictionary, locationNames) {
|
|
971
|
+
const types = [].concat(pathFilters.propertyType || []).filter(Boolean);
|
|
972
|
+
let noun = "Im\xF3veis";
|
|
973
|
+
let found = "encontrados";
|
|
974
|
+
if (types.length === 1) {
|
|
975
|
+
const id = String(types[0]);
|
|
976
|
+
const option = dictionary?.propertyTypes?.find(
|
|
977
|
+
(entry) => entry.id === id || entry.slug === id
|
|
978
|
+
);
|
|
979
|
+
const label = option?.label;
|
|
980
|
+
if (label) {
|
|
981
|
+
noun = pluralizePt(label.charAt(0).toUpperCase() + label.slice(1));
|
|
982
|
+
if (FEMININE_HEADING.test(id) || FEMININE_HEADING.test(label)) {
|
|
983
|
+
found = "encontradas";
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
const place = locationNames ? headingLocationSuffix(
|
|
988
|
+
displayPathLocation(pathFilters.location, locationNames)
|
|
989
|
+
) : "";
|
|
990
|
+
if (place) return `${noun} ${found} em ${place}`;
|
|
991
|
+
return `${noun} ${found}`;
|
|
992
|
+
}
|
|
993
|
+
function hrefWithExplicitPage(href, page) {
|
|
994
|
+
if (page !== 1 || /(?:\?|&)page=/.test(href)) return href;
|
|
995
|
+
return href.includes("?") ? `${href}&page=1` : `${href}?page=1`;
|
|
996
|
+
}
|
|
984
997
|
function paginationPages(currentPage, totalPages, padding) {
|
|
985
998
|
if (totalPages < 1) return [];
|
|
986
999
|
const current = Math.min(Math.max(1, currentPage), totalPages);
|
|
@@ -1004,10 +1017,9 @@ function RangeFields({
|
|
|
1004
1017
|
const patch = (side, raw) => {
|
|
1005
1018
|
onRangePatch(filter.id, side, isPrice ? formatGroupedInteger(raw) : raw);
|
|
1006
1019
|
};
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.
|
|
1010
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex gap-2", children: [
|
|
1020
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("fieldset", { "data-slot": "search-filter", children: [
|
|
1021
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("legend", { children: filter.label }),
|
|
1022
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-slot": "search-range-row", children: [
|
|
1011
1023
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1012
1024
|
RangeSide,
|
|
1013
1025
|
{
|
|
@@ -1015,9 +1027,9 @@ function RangeFields({
|
|
|
1015
1027
|
label: "M\xEDn",
|
|
1016
1028
|
isPrice,
|
|
1017
1029
|
value: draft.min,
|
|
1018
|
-
inputClass,
|
|
1019
1030
|
onPatch: (raw) => patch("min", raw),
|
|
1020
|
-
onCommit: () => onRangeCommit(filter.id)
|
|
1031
|
+
onCommit: () => onRangeCommit(filter.id, "blur"),
|
|
1032
|
+
onEnter: () => onRangeCommit(filter.id, "enter")
|
|
1021
1033
|
}
|
|
1022
1034
|
),
|
|
1023
1035
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -1027,9 +1039,18 @@ function RangeFields({
|
|
|
1027
1039
|
label: "M\xE1x",
|
|
1028
1040
|
isPrice,
|
|
1029
1041
|
value: draft.max,
|
|
1030
|
-
inputClass,
|
|
1031
1042
|
onPatch: (raw) => patch("max", raw),
|
|
1032
|
-
onCommit: () => onRangeCommit(filter.id)
|
|
1043
|
+
onCommit: () => onRangeCommit(filter.id, "blur"),
|
|
1044
|
+
onEnter: () => onRangeCommit(filter.id, "enter")
|
|
1045
|
+
}
|
|
1046
|
+
),
|
|
1047
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1048
|
+
"button",
|
|
1049
|
+
{
|
|
1050
|
+
type: "button",
|
|
1051
|
+
"data-slot": "search-range-apply",
|
|
1052
|
+
onClick: () => onRangeCommit(filter.id, "apply"),
|
|
1053
|
+
children: "Atualizar"
|
|
1033
1054
|
}
|
|
1034
1055
|
)
|
|
1035
1056
|
] })
|
|
@@ -1040,9 +1061,9 @@ function RangeSide({
|
|
|
1040
1061
|
label,
|
|
1041
1062
|
isPrice,
|
|
1042
1063
|
value,
|
|
1043
|
-
inputClass,
|
|
1044
1064
|
onPatch,
|
|
1045
|
-
onCommit
|
|
1065
|
+
onCommit,
|
|
1066
|
+
onEnter
|
|
1046
1067
|
}) {
|
|
1047
1068
|
const input = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1048
1069
|
"input",
|
|
@@ -1057,15 +1078,18 @@ function RangeSide({
|
|
|
1057
1078
|
onChange: (event) => onPatch(event.target.value),
|
|
1058
1079
|
onBlur: onCommit,
|
|
1059
1080
|
onKeyDown: (event) => {
|
|
1060
|
-
if (event.key === "Enter")
|
|
1081
|
+
if (event.key === "Enter") {
|
|
1082
|
+
event.preventDefault();
|
|
1083
|
+
onEnter();
|
|
1084
|
+
}
|
|
1061
1085
|
},
|
|
1062
|
-
|
|
1086
|
+
"data-slot": "search-range-input"
|
|
1063
1087
|
}
|
|
1064
1088
|
);
|
|
1065
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", {
|
|
1066
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
|
|
1067
|
-
isPrice ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", {
|
|
1068
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
|
|
1089
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { "data-slot": "search-range-side", htmlFor: id, children: [
|
|
1090
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: label }),
|
|
1091
|
+
isPrice ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { "data-slot": "search-range-affix", children: [
|
|
1092
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-slot": "search-range-prefix", children: "R$" }),
|
|
1069
1093
|
input
|
|
1070
1094
|
] }) : input
|
|
1071
1095
|
] });
|
|
@@ -1077,17 +1101,15 @@ function CountFields({
|
|
|
1077
1101
|
}) {
|
|
1078
1102
|
const selected = pathFilterValue(pathFilters, filter.id);
|
|
1079
1103
|
const choices = countFacetChoices(filter.options);
|
|
1080
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("fieldset", {
|
|
1081
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("legend", {
|
|
1082
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", {
|
|
1104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("fieldset", { "data-slot": "search-filter", children: [
|
|
1105
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("legend", { children: filter.label }),
|
|
1106
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-slot": "search-count-group", role: "group", children: choices.map((choice) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1083
1107
|
"button",
|
|
1084
1108
|
{
|
|
1085
1109
|
type: "button",
|
|
1110
|
+
"data-slot": "search-count-choice",
|
|
1111
|
+
"data-selected": selected === choice.id ? "true" : void 0,
|
|
1086
1112
|
onClick: () => onChange(filter.id, Number(choice.id)),
|
|
1087
|
-
className: cn(
|
|
1088
|
-
"min-h-10 cursor-pointer rounded-lg border px-3 text-sm hover:bg-muted",
|
|
1089
|
-
selected === choice.id && "border-primary bg-primary/10"
|
|
1090
|
-
),
|
|
1091
1113
|
children: choice.label
|
|
1092
1114
|
},
|
|
1093
1115
|
choice.id
|
|
@@ -1101,36 +1123,20 @@ function EnumFields({
|
|
|
1101
1123
|
}) {
|
|
1102
1124
|
const options = filter.options || [];
|
|
1103
1125
|
const scroll = options.length > 8;
|
|
1104
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("fieldset", {
|
|
1105
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("legend", {
|
|
1106
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1119
|
-
"input",
|
|
1120
|
-
{
|
|
1121
|
-
type: "checkbox",
|
|
1122
|
-
checked: pathFilterHasOption(pathFilters, filter.id, option.id),
|
|
1123
|
-
onChange: () => onChange(filter.id, option.id),
|
|
1124
|
-
className: "cursor-pointer"
|
|
1125
|
-
}
|
|
1126
|
-
),
|
|
1127
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: option.label })
|
|
1128
|
-
]
|
|
1129
|
-
},
|
|
1130
|
-
option.id
|
|
1131
|
-
))
|
|
1132
|
-
}
|
|
1133
|
-
)
|
|
1126
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("fieldset", { "data-slot": "search-filter", children: [
|
|
1127
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("legend", { children: filter.label }),
|
|
1128
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-slot": scroll ? "search-scroll" : "search-enum-list", children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { "data-slot": "search-enum-option", children: [
|
|
1129
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1130
|
+
"input",
|
|
1131
|
+
{
|
|
1132
|
+
type: "checkbox",
|
|
1133
|
+
"data-slot": "search-checkbox",
|
|
1134
|
+
checked: pathFilterHasOption(pathFilters, filter.id, option.id),
|
|
1135
|
+
onChange: () => onChange(filter.id, option.id)
|
|
1136
|
+
}
|
|
1137
|
+
),
|
|
1138
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: option.label })
|
|
1139
|
+
] }, option.id)) })
|
|
1134
1140
|
] });
|
|
1135
1141
|
}
|
|
1136
1142
|
function FilterPanel({
|
|
@@ -1141,7 +1147,7 @@ function FilterPanel({
|
|
|
1141
1147
|
onRangePatch,
|
|
1142
1148
|
onRangeCommit
|
|
1143
1149
|
}) {
|
|
1144
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", {
|
|
1150
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-slot": "search-filters", children: filters.map((filter) => {
|
|
1145
1151
|
if (filter.type === "range") {
|
|
1146
1152
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1147
1153
|
RangeFields,
|
|
@@ -1200,15 +1206,15 @@ function SearchSortSelect({
|
|
|
1200
1206
|
className
|
|
1201
1207
|
}) {
|
|
1202
1208
|
const options = searchSortOptions(sorts);
|
|
1203
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", {
|
|
1204
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
|
|
1209
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { "data-slot": "search-sort", className, children: [
|
|
1210
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "data-slot": "search-label", children: "Ordenar" }),
|
|
1205
1211
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1206
1212
|
"select",
|
|
1207
1213
|
{
|
|
1208
1214
|
id: "garagem-search-sort",
|
|
1215
|
+
"data-slot": "search-sort-trigger",
|
|
1209
1216
|
value,
|
|
1210
1217
|
onChange: (event) => onChange(event.target.value || null),
|
|
1211
|
-
className: "min-h-10 cursor-pointer rounded-lg border border-border bg-background px-3",
|
|
1212
1218
|
children: options.map((sort) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: sort.id, children: sort.label }, sort.id || "relevance"))
|
|
1213
1219
|
}
|
|
1214
1220
|
)
|
|
@@ -1217,37 +1223,22 @@ function SearchSortSelect({
|
|
|
1217
1223
|
function ResultsSkeleton({
|
|
1218
1224
|
className
|
|
1219
1225
|
}) {
|
|
1220
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.
|
|
1221
|
-
|
|
1222
|
-
{
|
|
1223
|
-
"data-slot": "search-skeleton",
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
className: "animate-pulse bg-muted",
|
|
1237
|
-
style: { aspectRatio: "4 / 3" }
|
|
1238
|
-
}
|
|
1239
|
-
),
|
|
1240
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "space-y-2 p-4", children: [
|
|
1241
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "h-5 w-1/2 animate-pulse rounded bg-muted" }),
|
|
1242
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "h-4 w-3/4 animate-pulse rounded bg-muted" }),
|
|
1243
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "h-3 w-2/3 animate-pulse rounded bg-muted" })
|
|
1244
|
-
] })
|
|
1245
|
-
]
|
|
1246
|
-
},
|
|
1247
|
-
i
|
|
1248
|
-
))
|
|
1249
|
-
}
|
|
1250
|
-
);
|
|
1226
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
1227
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SearchChromeStyles, {}),
|
|
1228
|
+
/* @__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: [
|
|
1229
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "media" }),
|
|
1230
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-slot": "search-skeleton-body", children: [
|
|
1231
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "line-lg" }),
|
|
1232
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "line-md" }),
|
|
1233
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "line-sm" })
|
|
1234
|
+
] })
|
|
1235
|
+
] }, i)) })
|
|
1236
|
+
] });
|
|
1237
|
+
}
|
|
1238
|
+
function SearchPageFallback({
|
|
1239
|
+
className
|
|
1240
|
+
}) {
|
|
1241
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("main", { "data-slot": "search-page", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ResultsSkeleton, { className }) });
|
|
1251
1242
|
}
|
|
1252
1243
|
|
|
1253
1244
|
// src/react/search-pagination.tsx
|
|
@@ -1258,78 +1249,83 @@ function NavItem({
|
|
|
1258
1249
|
label,
|
|
1259
1250
|
disabled,
|
|
1260
1251
|
current,
|
|
1261
|
-
|
|
1252
|
+
onNavigate
|
|
1262
1253
|
}) {
|
|
1263
|
-
const itemClass = cn(
|
|
1264
|
-
"inline-flex size-8 cursor-pointer items-center justify-center rounded-md border text-xs font-medium md:size-9",
|
|
1265
|
-
current && "bg-primary text-primary-foreground",
|
|
1266
|
-
disabled && "cursor-not-allowed text-muted-foreground",
|
|
1267
|
-
className
|
|
1268
|
-
);
|
|
1269
1254
|
if (disabled || !href || current) {
|
|
1270
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1255
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1256
|
+
"li",
|
|
1257
|
+
{
|
|
1258
|
+
"data-slot": "search-pagination-item",
|
|
1259
|
+
"data-current": current ? "true" : void 0,
|
|
1260
|
+
"data-disabled": disabled ? "true" : void 0,
|
|
1261
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: label })
|
|
1262
|
+
}
|
|
1263
|
+
);
|
|
1271
1264
|
}
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
{
|
|
1275
|
-
|
|
1276
|
-
className: "flex size-full items-center justify-center",
|
|
1277
|
-
"aria-label": label,
|
|
1278
|
-
children: label
|
|
1265
|
+
function handleClick(event) {
|
|
1266
|
+
if (!onNavigate || !href) return;
|
|
1267
|
+
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0) {
|
|
1268
|
+
return;
|
|
1279
1269
|
}
|
|
1280
|
-
|
|
1270
|
+
event.preventDefault();
|
|
1271
|
+
onNavigate(href);
|
|
1272
|
+
}
|
|
1273
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { "data-slot": "search-pagination-item", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_link2.default, { href, onClick: handleClick, "aria-label": label, children: label }) });
|
|
1281
1274
|
}
|
|
1282
1275
|
function SearchPagination({
|
|
1283
1276
|
page,
|
|
1284
1277
|
totalPages,
|
|
1285
1278
|
hrefForPage,
|
|
1279
|
+
onNavigate,
|
|
1286
1280
|
className
|
|
1287
1281
|
}) {
|
|
1288
1282
|
if (totalPages <= 1) return null;
|
|
1289
|
-
const
|
|
1290
|
-
const desktop = paginationPages(page, totalPages, 2);
|
|
1283
|
+
const pages = paginationPages(page, totalPages, 2);
|
|
1291
1284
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1292
1285
|
"nav",
|
|
1293
1286
|
{
|
|
1294
1287
|
"data-slot": "search-pagination",
|
|
1295
|
-
className
|
|
1288
|
+
className,
|
|
1296
1289
|
"aria-label": "Pagina\xE7\xE3o",
|
|
1297
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("ul", {
|
|
1298
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NavItem, { href: hrefForPage(1), label: "\u2039\u2039", disabled: page <= 1 }),
|
|
1290
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("ul", { children: [
|
|
1299
1291
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1300
1292
|
NavItem,
|
|
1301
1293
|
{
|
|
1302
|
-
href: hrefForPage(
|
|
1303
|
-
label: "\u2039",
|
|
1304
|
-
disabled: page <= 1
|
|
1294
|
+
href: hrefWithExplicitPage(hrefForPage(1), 1),
|
|
1295
|
+
label: "\u2039\u2039",
|
|
1296
|
+
disabled: page <= 1,
|
|
1297
|
+
onNavigate
|
|
1305
1298
|
}
|
|
1306
1299
|
),
|
|
1307
|
-
|
|
1300
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1308
1301
|
NavItem,
|
|
1309
1302
|
{
|
|
1310
|
-
href:
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1303
|
+
href: hrefWithExplicitPage(
|
|
1304
|
+
hrefForPage(Math.max(1, page - 1)),
|
|
1305
|
+
Math.max(1, page - 1)
|
|
1306
|
+
),
|
|
1307
|
+
label: "\u2039",
|
|
1308
|
+
disabled: page <= 1,
|
|
1309
|
+
onNavigate
|
|
1310
|
+
}
|
|
1311
|
+
),
|
|
1312
|
+
pages.map((n) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1318
1313
|
NavItem,
|
|
1319
1314
|
{
|
|
1320
|
-
href: hrefForPage(n),
|
|
1315
|
+
href: hrefWithExplicitPage(hrefForPage(n), n),
|
|
1321
1316
|
label: String(n),
|
|
1322
1317
|
current: n === page,
|
|
1323
|
-
|
|
1318
|
+
onNavigate
|
|
1324
1319
|
},
|
|
1325
|
-
|
|
1320
|
+
n
|
|
1326
1321
|
)),
|
|
1327
1322
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1328
1323
|
NavItem,
|
|
1329
1324
|
{
|
|
1330
1325
|
href: hrefForPage(Math.min(totalPages, page + 1)),
|
|
1331
1326
|
label: "\u203A",
|
|
1332
|
-
disabled: page >= totalPages
|
|
1327
|
+
disabled: page >= totalPages,
|
|
1328
|
+
onNavigate
|
|
1333
1329
|
}
|
|
1334
1330
|
),
|
|
1335
1331
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
@@ -1337,7 +1333,8 @@ function SearchPagination({
|
|
|
1337
1333
|
{
|
|
1338
1334
|
href: hrefForPage(totalPages),
|
|
1339
1335
|
label: "\u203A\u203A",
|
|
1340
|
-
disabled: page >= totalPages
|
|
1336
|
+
disabled: page >= totalPages,
|
|
1337
|
+
onNavigate
|
|
1341
1338
|
}
|
|
1342
1339
|
)
|
|
1343
1340
|
] })
|
|
@@ -1345,79 +1342,108 @@ function SearchPagination({
|
|
|
1345
1342
|
);
|
|
1346
1343
|
}
|
|
1347
1344
|
|
|
1348
|
-
// src/react/
|
|
1345
|
+
// src/react/icons.tsx
|
|
1349
1346
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1347
|
+
function Icon({ children, ...props }) {
|
|
1348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1349
|
+
"svg",
|
|
1350
|
+
{
|
|
1351
|
+
viewBox: "0 0 24 24",
|
|
1352
|
+
fill: "none",
|
|
1353
|
+
stroke: "currentColor",
|
|
1354
|
+
strokeWidth: 2,
|
|
1355
|
+
strokeLinecap: "round",
|
|
1356
|
+
strokeLinejoin: "round",
|
|
1357
|
+
"aria-hidden": true,
|
|
1358
|
+
"data-slot": "search-icon",
|
|
1359
|
+
...props,
|
|
1360
|
+
children
|
|
1361
|
+
}
|
|
1362
|
+
);
|
|
1363
|
+
}
|
|
1364
|
+
function SearchLensIcon(props) {
|
|
1365
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Icon, { ...props, children: [
|
|
1366
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { cx: "11", cy: "11", r: "7" }),
|
|
1367
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M20 20l-3.5-3.5" })
|
|
1368
|
+
] });
|
|
1369
|
+
}
|
|
1370
|
+
function SearchClearIcon(props) {
|
|
1371
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M6 6l12 12M18 6L6 18" }) });
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
// src/react/search-query-form.tsx
|
|
1375
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1350
1376
|
function SearchQueryForm({
|
|
1351
1377
|
value,
|
|
1352
1378
|
onChange,
|
|
1353
1379
|
onSubmit,
|
|
1354
1380
|
onClear,
|
|
1355
|
-
className
|
|
1381
|
+
className,
|
|
1382
|
+
iconClassName,
|
|
1383
|
+
searchIcon,
|
|
1384
|
+
clearIcon
|
|
1356
1385
|
}) {
|
|
1357
1386
|
function handleSubmit(event) {
|
|
1358
1387
|
event.preventDefault();
|
|
1359
1388
|
onSubmit();
|
|
1360
1389
|
}
|
|
1361
|
-
return /* @__PURE__ */ (0,
|
|
1390
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1362
1391
|
"form",
|
|
1363
1392
|
{
|
|
1364
1393
|
role: "search",
|
|
1365
1394
|
"data-slot": "search-query",
|
|
1366
1395
|
onSubmit: handleSubmit,
|
|
1367
|
-
className
|
|
1368
|
-
children:
|
|
1369
|
-
/* @__PURE__ */ (0,
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
htmlFor: "garagem-search-q",
|
|
1373
|
-
className: "mb-1 block text-sm text-muted-foreground",
|
|
1374
|
-
children: "Busca"
|
|
1375
|
-
}
|
|
1376
|
-
),
|
|
1377
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative", children: [
|
|
1378
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1396
|
+
className,
|
|
1397
|
+
children: [
|
|
1398
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { htmlFor: "garagem-search-q", "data-slot": "search-label", children: "Busca" }),
|
|
1399
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { "data-slot": "search-query-field", children: [
|
|
1400
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1379
1401
|
"input",
|
|
1380
1402
|
{
|
|
1381
1403
|
id: "garagem-search-q",
|
|
1382
1404
|
name: "q",
|
|
1383
|
-
type: "
|
|
1405
|
+
type: "text",
|
|
1406
|
+
inputMode: "search",
|
|
1384
1407
|
autoComplete: "off",
|
|
1385
1408
|
enterKeyHint: "search",
|
|
1386
1409
|
value,
|
|
1387
1410
|
onChange: (event) => onChange(event.target.value),
|
|
1388
1411
|
placeholder: "Busque por bairro, rua ou c\xF3digo",
|
|
1389
|
-
|
|
1412
|
+
"data-slot": "search-query-input"
|
|
1390
1413
|
}
|
|
1391
1414
|
),
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1415
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { "data-slot": "search-query-actions", children: [
|
|
1416
|
+
value ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1417
|
+
"button",
|
|
1418
|
+
{
|
|
1419
|
+
type: "button",
|
|
1420
|
+
title: "Limpar busca",
|
|
1421
|
+
"aria-label": "Limpar busca",
|
|
1422
|
+
onClick: onClear,
|
|
1423
|
+
"data-slot": "search-icon-button",
|
|
1424
|
+
"data-kind": "clear",
|
|
1425
|
+
children: clearIcon ?? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SearchClearIcon, { className: iconClassName })
|
|
1426
|
+
}
|
|
1427
|
+
) : null,
|
|
1428
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1429
|
+
"button",
|
|
1430
|
+
{
|
|
1431
|
+
type: "submit",
|
|
1432
|
+
title: "Buscar",
|
|
1433
|
+
"aria-label": "Buscar",
|
|
1434
|
+
"data-slot": "search-icon-button",
|
|
1435
|
+
children: searchIcon ?? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SearchLensIcon, { className: iconClassName })
|
|
1436
|
+
}
|
|
1437
|
+
)
|
|
1438
|
+
] })
|
|
1413
1439
|
] })
|
|
1414
|
-
]
|
|
1440
|
+
]
|
|
1415
1441
|
}
|
|
1416
1442
|
);
|
|
1417
1443
|
}
|
|
1418
1444
|
|
|
1419
1445
|
// src/react/use-public-search.ts
|
|
1420
|
-
var
|
|
1446
|
+
var import_react2 = require("react");
|
|
1421
1447
|
var import_navigation = require("next/navigation");
|
|
1422
1448
|
|
|
1423
1449
|
// src/internal/url.ts
|
|
@@ -1503,33 +1529,36 @@ function usePublicSearch(options) {
|
|
|
1503
1529
|
const pathname = (0, import_navigation.usePathname)() || "/imoveis";
|
|
1504
1530
|
const searchParams = (0, import_navigation.useSearchParams)();
|
|
1505
1531
|
const search = searchParams.toString();
|
|
1506
|
-
const siteIdRef = (0,
|
|
1532
|
+
const siteIdRef = (0, import_react2.useRef)(siteId);
|
|
1507
1533
|
siteIdRef.current = siteId;
|
|
1508
1534
|
const siteIdToken = typeof siteId === "string" ? siteId : null;
|
|
1509
|
-
const [catalogId, setCatalogId] = (0,
|
|
1510
|
-
const [schema, setSchema] = (0,
|
|
1511
|
-
const [listings, setListings] = (0,
|
|
1512
|
-
const [page, setPage] = (0,
|
|
1513
|
-
const [total, setTotal] = (0,
|
|
1514
|
-
const [totalPages, setTotalPages] = (0,
|
|
1515
|
-
const [loading, setLoading] = (0,
|
|
1516
|
-
const [qDraft, setQDraft] = (0,
|
|
1517
|
-
const [staged, setStaged] = (0,
|
|
1518
|
-
const
|
|
1535
|
+
const [catalogId, setCatalogId] = (0, import_react2.useState)(null);
|
|
1536
|
+
const [schema, setSchema] = (0, import_react2.useState)(null);
|
|
1537
|
+
const [listings, setListings] = (0, import_react2.useState)([]);
|
|
1538
|
+
const [page, setPage] = (0, import_react2.useState)(1);
|
|
1539
|
+
const [total, setTotal] = (0, import_react2.useState)(0);
|
|
1540
|
+
const [totalPages, setTotalPages] = (0, import_react2.useState)(1);
|
|
1541
|
+
const [loading, setLoading] = (0, import_react2.useState)(true);
|
|
1542
|
+
const [qDraft, setQDraft] = (0, import_react2.useState)("");
|
|
1543
|
+
const [staged, setStaged] = (0, import_react2.useState)({});
|
|
1544
|
+
const [locationNames, setLocationNames] = (0, import_react2.useState)(
|
|
1545
|
+
null
|
|
1546
|
+
);
|
|
1547
|
+
const parsed = (0, import_react2.useMemo)(
|
|
1519
1548
|
() => readPublicSearch(pathname, search, schema?.dictionary),
|
|
1520
1549
|
[pathname, search, schema?.dictionary]
|
|
1521
1550
|
);
|
|
1522
|
-
(0,
|
|
1551
|
+
(0, import_react2.useEffect)(() => {
|
|
1523
1552
|
setQDraft(parsed.applied.query || "");
|
|
1524
1553
|
}, [parsed.applied.query]);
|
|
1525
|
-
const resetStagedFromUrl = (0,
|
|
1554
|
+
const resetStagedFromUrl = (0, import_react2.useCallback)(() => {
|
|
1526
1555
|
setStaged({ ...parsed.pathFilters });
|
|
1527
1556
|
}, [parsed.pathFilters]);
|
|
1528
|
-
(0,
|
|
1557
|
+
(0, import_react2.useEffect)(() => {
|
|
1529
1558
|
setStaged({ ...parsed.pathFilters });
|
|
1530
1559
|
}, [parsed.pathFilters]);
|
|
1531
|
-
const locationsRef = (0,
|
|
1532
|
-
(0,
|
|
1560
|
+
const locationsRef = (0, import_react2.useRef)(null);
|
|
1561
|
+
(0, import_react2.useEffect)(() => {
|
|
1533
1562
|
if (!schema) return;
|
|
1534
1563
|
const canonical = canonicalizeSearchHref(
|
|
1535
1564
|
pathname,
|
|
@@ -1538,7 +1567,7 @@ function usePublicSearch(options) {
|
|
|
1538
1567
|
);
|
|
1539
1568
|
if (canonical) router.replace(canonical);
|
|
1540
1569
|
}, [pathname, search, schema, router]);
|
|
1541
|
-
(0,
|
|
1570
|
+
(0, import_react2.useEffect)(() => {
|
|
1542
1571
|
let active = true;
|
|
1543
1572
|
setCatalogId(null);
|
|
1544
1573
|
setSchema(null);
|
|
@@ -1553,11 +1582,12 @@ function usePublicSearch(options) {
|
|
|
1553
1582
|
active = false;
|
|
1554
1583
|
};
|
|
1555
1584
|
}, [baseUrl, siteIdToken]);
|
|
1556
|
-
(0,
|
|
1585
|
+
(0, import_react2.useEffect)(() => {
|
|
1557
1586
|
if (!catalogId) return;
|
|
1558
1587
|
const id = catalogId;
|
|
1559
1588
|
let active = true;
|
|
1560
1589
|
locationsRef.current = null;
|
|
1590
|
+
setLocationNames(null);
|
|
1561
1591
|
setSchema(null);
|
|
1562
1592
|
setListings([]);
|
|
1563
1593
|
setLoading(true);
|
|
@@ -1580,10 +1610,12 @@ function usePublicSearch(options) {
|
|
|
1580
1610
|
}
|
|
1581
1611
|
if (!active) return;
|
|
1582
1612
|
locationsRef.current = locations;
|
|
1613
|
+
setLocationNames(locations);
|
|
1583
1614
|
setSchema(nextSchema);
|
|
1584
1615
|
} catch {
|
|
1585
1616
|
if (active) {
|
|
1586
1617
|
locationsRef.current = null;
|
|
1618
|
+
setLocationNames(null);
|
|
1587
1619
|
setSchema(null);
|
|
1588
1620
|
setLoading(false);
|
|
1589
1621
|
}
|
|
@@ -1594,7 +1626,7 @@ function usePublicSearch(options) {
|
|
|
1594
1626
|
active = false;
|
|
1595
1627
|
};
|
|
1596
1628
|
}, [baseUrl, catalogId]);
|
|
1597
|
-
(0,
|
|
1629
|
+
(0, import_react2.useEffect)(() => {
|
|
1598
1630
|
if (!schema || !catalogId) return;
|
|
1599
1631
|
const currentSchema = schema;
|
|
1600
1632
|
const id = catalogId;
|
|
@@ -1638,13 +1670,13 @@ function usePublicSearch(options) {
|
|
|
1638
1670
|
active = false;
|
|
1639
1671
|
};
|
|
1640
1672
|
}, [pathname, search, baseUrl, schema, catalogId]);
|
|
1641
|
-
const go = (0,
|
|
1673
|
+
const go = (0, import_react2.useCallback)(
|
|
1642
1674
|
(href) => {
|
|
1643
1675
|
if (href && href !== currentHref(pathname, search)) router.push(href);
|
|
1644
1676
|
},
|
|
1645
1677
|
[pathname, search, router]
|
|
1646
1678
|
);
|
|
1647
|
-
const applyFilter = (0,
|
|
1679
|
+
const applyFilter = (0, import_react2.useCallback)(
|
|
1648
1680
|
(filterId, value) => {
|
|
1649
1681
|
if (!schema) return;
|
|
1650
1682
|
go(
|
|
@@ -1658,17 +1690,17 @@ function usePublicSearch(options) {
|
|
|
1658
1690
|
},
|
|
1659
1691
|
[go, pathname, search, schema, parsed.pathFilters]
|
|
1660
1692
|
);
|
|
1661
|
-
const stageFilter = (0,
|
|
1693
|
+
const stageFilter = (0, import_react2.useCallback)((filterId, value) => {
|
|
1662
1694
|
setStaged((current) => applyPathFilter(current, filterId, value));
|
|
1663
1695
|
}, []);
|
|
1664
|
-
const applyStaged = (0,
|
|
1696
|
+
const applyStaged = (0, import_react2.useCallback)(() => {
|
|
1665
1697
|
if (!schema) return;
|
|
1666
1698
|
go(hrefForPathFilters(pathname, search, schema.dictionary, staged));
|
|
1667
1699
|
}, [go, pathname, search, schema, staged]);
|
|
1668
|
-
const clearStaged = (0,
|
|
1700
|
+
const clearStaged = (0, import_react2.useCallback)(() => {
|
|
1669
1701
|
setStaged((current) => clearStagedPathFilters(current));
|
|
1670
1702
|
}, []);
|
|
1671
|
-
const submitQuery = (0,
|
|
1703
|
+
const submitQuery = (0, import_react2.useCallback)(() => {
|
|
1672
1704
|
if (!schema) return;
|
|
1673
1705
|
go(
|
|
1674
1706
|
hrefForAppliedChange(pathname, search, schema.dictionary, {
|
|
@@ -1677,7 +1709,7 @@ function usePublicSearch(options) {
|
|
|
1677
1709
|
})
|
|
1678
1710
|
);
|
|
1679
1711
|
}, [go, pathname, search, schema, qDraft]);
|
|
1680
|
-
const clearQuery = (0,
|
|
1712
|
+
const clearQuery = (0, import_react2.useCallback)(() => {
|
|
1681
1713
|
setQDraft("");
|
|
1682
1714
|
if (!schema) return;
|
|
1683
1715
|
go(
|
|
@@ -1687,7 +1719,7 @@ function usePublicSearch(options) {
|
|
|
1687
1719
|
})
|
|
1688
1720
|
);
|
|
1689
1721
|
}, [go, pathname, search, schema]);
|
|
1690
|
-
const setSort = (0,
|
|
1722
|
+
const setSort = (0, import_react2.useCallback)(
|
|
1691
1723
|
(sort) => {
|
|
1692
1724
|
if (!schema) return;
|
|
1693
1725
|
go(
|
|
@@ -1699,7 +1731,7 @@ function usePublicSearch(options) {
|
|
|
1699
1731
|
},
|
|
1700
1732
|
[go, pathname, search, schema]
|
|
1701
1733
|
);
|
|
1702
|
-
const hrefForPage = (0,
|
|
1734
|
+
const hrefForPage = (0, import_react2.useCallback)(
|
|
1703
1735
|
(nextPage) => {
|
|
1704
1736
|
if (!schema) return pathname;
|
|
1705
1737
|
return hrefForAppliedChange(pathname, search, schema.dictionary, {
|
|
@@ -1733,44 +1765,75 @@ function usePublicSearch(options) {
|
|
|
1733
1765
|
clearQuery,
|
|
1734
1766
|
setSort,
|
|
1735
1767
|
hrefForPage,
|
|
1736
|
-
go
|
|
1768
|
+
go,
|
|
1769
|
+
locationNames
|
|
1737
1770
|
};
|
|
1738
1771
|
}
|
|
1739
1772
|
|
|
1740
1773
|
// src/react/search-page.tsx
|
|
1741
|
-
var
|
|
1774
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1742
1775
|
function ToolbarPopover({
|
|
1776
|
+
id,
|
|
1743
1777
|
label,
|
|
1778
|
+
open,
|
|
1779
|
+
onOpenChange,
|
|
1780
|
+
triggerClassName,
|
|
1781
|
+
popoverClassName,
|
|
1744
1782
|
children
|
|
1745
1783
|
}) {
|
|
1746
|
-
const
|
|
1747
|
-
|
|
1748
|
-
|
|
1784
|
+
const rootRef = (0, import_react3.useRef)(null);
|
|
1785
|
+
(0, import_react3.useEffect)(() => {
|
|
1786
|
+
if (!open) return;
|
|
1787
|
+
function onPointer(event) {
|
|
1788
|
+
if (!rootRef.current?.contains(event.target)) {
|
|
1789
|
+
onOpenChange(null);
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
function onKey(event) {
|
|
1793
|
+
if (event.key === "Escape") onOpenChange(null);
|
|
1794
|
+
}
|
|
1795
|
+
document.addEventListener("mousedown", onPointer);
|
|
1796
|
+
document.addEventListener("keydown", onKey);
|
|
1797
|
+
return () => {
|
|
1798
|
+
document.removeEventListener("mousedown", onPointer);
|
|
1799
|
+
document.removeEventListener("keydown", onKey);
|
|
1800
|
+
};
|
|
1801
|
+
}, [open, onOpenChange]);
|
|
1802
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-slot": "search-toolbar-item", ref: rootRef, children: [
|
|
1803
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1749
1804
|
"button",
|
|
1750
1805
|
{
|
|
1751
1806
|
type: "button",
|
|
1752
|
-
|
|
1753
|
-
className:
|
|
1807
|
+
"data-slot": "search-toolbar-trigger",
|
|
1808
|
+
className: triggerClassName,
|
|
1809
|
+
"aria-expanded": open,
|
|
1810
|
+
onClick: () => onOpenChange(open ? null : id),
|
|
1754
1811
|
children: label
|
|
1755
1812
|
}
|
|
1756
1813
|
),
|
|
1757
|
-
open ? /* @__PURE__ */ (0,
|
|
1814
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1815
|
+
"div",
|
|
1816
|
+
{
|
|
1817
|
+
"data-slot": "search-popover",
|
|
1818
|
+
className: popoverClassName,
|
|
1819
|
+
role: "dialog",
|
|
1820
|
+
children
|
|
1821
|
+
}
|
|
1822
|
+
) : null
|
|
1758
1823
|
] });
|
|
1759
1824
|
}
|
|
1760
1825
|
function FiltersTrigger({
|
|
1761
1826
|
onClick,
|
|
1762
1827
|
className
|
|
1763
1828
|
}) {
|
|
1764
|
-
return /* @__PURE__ */ (0,
|
|
1829
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1765
1830
|
"button",
|
|
1766
1831
|
{
|
|
1767
1832
|
type: "button",
|
|
1768
1833
|
title: "Filtros",
|
|
1834
|
+
"data-slot": "search-filters-trigger",
|
|
1769
1835
|
onClick,
|
|
1770
|
-
className
|
|
1771
|
-
"min-h-10 cursor-pointer rounded-lg border border-border px-3 text-sm hover:bg-muted",
|
|
1772
|
-
className
|
|
1773
|
-
),
|
|
1836
|
+
className,
|
|
1774
1837
|
children: "Filtros"
|
|
1775
1838
|
}
|
|
1776
1839
|
);
|
|
@@ -1780,27 +1843,82 @@ function ApplyBar({
|
|
|
1780
1843
|
onApply,
|
|
1781
1844
|
className
|
|
1782
1845
|
}) {
|
|
1783
|
-
return /* @__PURE__ */ (0,
|
|
1784
|
-
/* @__PURE__ */ (0,
|
|
1846
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-slot": "search-apply-bar", className, children: [
|
|
1847
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", "data-kind": "clear", onClick: onClear, children: "Limpar" }),
|
|
1848
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", "data-kind": "apply", onClick: onApply, children: "Ver resultados" })
|
|
1849
|
+
] });
|
|
1850
|
+
}
|
|
1851
|
+
function FilterSheet({
|
|
1852
|
+
open,
|
|
1853
|
+
title,
|
|
1854
|
+
onClose,
|
|
1855
|
+
overlayClassName,
|
|
1856
|
+
panelClassName,
|
|
1857
|
+
children,
|
|
1858
|
+
footer
|
|
1859
|
+
}) {
|
|
1860
|
+
const onCloseRef = (0, import_react3.useRef)(onClose);
|
|
1861
|
+
onCloseRef.current = onClose;
|
|
1862
|
+
(0, import_react3.useEffect)(() => {
|
|
1863
|
+
if (!open) return;
|
|
1864
|
+
function onKey(event) {
|
|
1865
|
+
if (event.key === "Escape") onCloseRef.current();
|
|
1866
|
+
}
|
|
1867
|
+
document.addEventListener("keydown", onKey);
|
|
1868
|
+
const previous = document.body.style.overflow;
|
|
1869
|
+
document.body.style.overflow = "hidden";
|
|
1870
|
+
return () => {
|
|
1871
|
+
document.removeEventListener("keydown", onKey);
|
|
1872
|
+
document.body.style.overflow = previous;
|
|
1873
|
+
};
|
|
1874
|
+
}, [open]);
|
|
1875
|
+
if (!open) return null;
|
|
1876
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-slot": "search-sheet", children: [
|
|
1877
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1785
1878
|
"button",
|
|
1786
1879
|
{
|
|
1787
1880
|
type: "button",
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1881
|
+
"aria-label": "Fechar filtros",
|
|
1882
|
+
"data-slot": "search-sheet-overlay",
|
|
1883
|
+
className: overlayClassName,
|
|
1884
|
+
onClick: onClose
|
|
1791
1885
|
}
|
|
1792
1886
|
),
|
|
1793
|
-
/* @__PURE__ */ (0,
|
|
1794
|
-
"
|
|
1887
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1888
|
+
"div",
|
|
1795
1889
|
{
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1890
|
+
"data-slot": "search-sheet-panel",
|
|
1891
|
+
className: panelClassName,
|
|
1892
|
+
role: "dialog",
|
|
1893
|
+
"aria-modal": "true",
|
|
1894
|
+
"aria-label": title,
|
|
1895
|
+
children: [
|
|
1896
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { "data-slot": "search-sheet-title", children: title }),
|
|
1897
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { "data-slot": "search-sheet-body", children }),
|
|
1898
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { "data-slot": "search-sheet-footer", children: footer })
|
|
1899
|
+
]
|
|
1800
1900
|
}
|
|
1801
1901
|
)
|
|
1802
1902
|
] });
|
|
1803
1903
|
}
|
|
1904
|
+
function SearchHeading({
|
|
1905
|
+
total,
|
|
1906
|
+
title,
|
|
1907
|
+
classNames,
|
|
1908
|
+
loading
|
|
1909
|
+
}) {
|
|
1910
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-slot": "search-heading", className: classNames?.heading, children: [
|
|
1911
|
+
!loading ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1912
|
+
"span",
|
|
1913
|
+
{
|
|
1914
|
+
"data-slot": "search-heading-count",
|
|
1915
|
+
className: classNames?.headingCount,
|
|
1916
|
+
children: total.toLocaleString("pt-BR")
|
|
1917
|
+
}
|
|
1918
|
+
) : null,
|
|
1919
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h1", { "data-slot": "search-heading-title", className: classNames?.headingTitle, children: title })
|
|
1920
|
+
] });
|
|
1921
|
+
}
|
|
1804
1922
|
function SearchPage({
|
|
1805
1923
|
siteId,
|
|
1806
1924
|
baseUrl,
|
|
@@ -1808,21 +1926,27 @@ function SearchPage({
|
|
|
1808
1926
|
className,
|
|
1809
1927
|
classNames,
|
|
1810
1928
|
heading,
|
|
1929
|
+
icons,
|
|
1811
1930
|
listingCard: Card = ListingCard
|
|
1812
1931
|
}) {
|
|
1813
1932
|
const search = usePublicSearch({ siteId, baseUrl });
|
|
1814
|
-
const
|
|
1815
|
-
const [
|
|
1816
|
-
const [rangeDraft, setRangeDraft] = (0,
|
|
1933
|
+
const [sheetOpen, setSheetOpen] = (0, import_react3.useState)(false);
|
|
1934
|
+
const [openToolbar, setOpenToolbar] = (0, import_react3.useState)(null);
|
|
1935
|
+
const [rangeDraft, setRangeDraft] = (0, import_react3.useState)(
|
|
1817
1936
|
() => rangeDraftFromPath(search.pathFilters)
|
|
1818
1937
|
);
|
|
1819
|
-
(0,
|
|
1938
|
+
(0, import_react3.useEffect)(() => {
|
|
1820
1939
|
setRangeDraft(rangeDraftFromPath(search.pathFilters));
|
|
1821
1940
|
}, [search.pathFilters]);
|
|
1822
1941
|
const filters = visibleSearchFilters(search.schema);
|
|
1823
1942
|
const toolbarIds = new Set(toolbarFilterIds(search.schema));
|
|
1824
1943
|
const toolbarFilters = filters.filter((filter) => toolbarIds.has(filter.id));
|
|
1825
1944
|
const extraFilters = filters.filter((filter) => !toolbarIds.has(filter.id));
|
|
1945
|
+
const headingTitle = searchResultsHeading(
|
|
1946
|
+
search.pathFilters,
|
|
1947
|
+
search.schema?.dictionary,
|
|
1948
|
+
search.locationNames
|
|
1949
|
+
);
|
|
1826
1950
|
function patchRange(filterId, side, value) {
|
|
1827
1951
|
setRangeDraft((prev) => ({
|
|
1828
1952
|
...prev,
|
|
@@ -1841,9 +1965,12 @@ function SearchPage({
|
|
|
1841
1965
|
function openStagedFilters() {
|
|
1842
1966
|
search.resetStagedFromUrl();
|
|
1843
1967
|
setRangeDraft(rangeDraftFromPath(search.pathFilters));
|
|
1844
|
-
|
|
1845
|
-
|
|
1968
|
+
setOpenToolbar(null);
|
|
1969
|
+
setSheetOpen(true);
|
|
1846
1970
|
}
|
|
1971
|
+
const closeSheet = (0, import_react3.useCallback)(() => {
|
|
1972
|
+
setSheetOpen(false);
|
|
1973
|
+
}, []);
|
|
1847
1974
|
function clearStagedFilters() {
|
|
1848
1975
|
const keepIds = variant === "toolbar" ? [...toolbarIds] : [];
|
|
1849
1976
|
const source = variant === "toolbar" ? search.pathFilters : search.staged;
|
|
@@ -1861,68 +1988,62 @@ function SearchPage({
|
|
|
1861
1988
|
}
|
|
1862
1989
|
function applyStagedAndClose() {
|
|
1863
1990
|
search.applyStaged();
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
}
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
search.total,
|
|
1870
|
-
" ",
|
|
1871
|
-
search.total === 1 ? "im\xF3vel encontrado" : "im\xF3veis encontrados"
|
|
1872
|
-
] }),
|
|
1873
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1874
|
-
"div",
|
|
1991
|
+
closeSheet();
|
|
1992
|
+
}
|
|
1993
|
+
const results = search.loading ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ResultsSkeleton, { className: classNames?.skeleton ?? classNames?.grid }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1994
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { "data-slot": "search-grid", className: classNames?.grid, children: search.listings.map((listing) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1995
|
+
Card,
|
|
1875
1996
|
{
|
|
1876
|
-
|
|
1877
|
-
className:
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
Card,
|
|
1883
|
-
{
|
|
1884
|
-
listing,
|
|
1885
|
-
className: classNames?.card
|
|
1886
|
-
},
|
|
1887
|
-
listing.id
|
|
1888
|
-
))
|
|
1889
|
-
}
|
|
1890
|
-
),
|
|
1891
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1997
|
+
listing,
|
|
1998
|
+
className: classNames?.card
|
|
1999
|
+
},
|
|
2000
|
+
listing.id
|
|
2001
|
+
)) }),
|
|
2002
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1892
2003
|
SearchPagination,
|
|
1893
2004
|
{
|
|
1894
2005
|
page: search.page,
|
|
1895
2006
|
totalPages: search.totalPages,
|
|
1896
2007
|
hrefForPage: search.hrefForPage,
|
|
2008
|
+
onNavigate: search.go,
|
|
1897
2009
|
className: classNames?.pagination
|
|
1898
2010
|
}
|
|
1899
2011
|
)
|
|
1900
2012
|
] });
|
|
1901
|
-
const queryAndSort = /* @__PURE__ */ (0,
|
|
1902
|
-
/* @__PURE__ */ (0,
|
|
2013
|
+
const queryAndSort = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-slot": "search-query-sort", children: [
|
|
2014
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1903
2015
|
SearchQueryForm,
|
|
1904
2016
|
{
|
|
1905
2017
|
value: search.qDraft,
|
|
1906
2018
|
onChange: search.setQDraft,
|
|
1907
2019
|
onSubmit: search.submitQuery,
|
|
1908
2020
|
onClear: search.clearQuery,
|
|
1909
|
-
className:
|
|
2021
|
+
className: classNames?.query,
|
|
2022
|
+
iconClassName: classNames?.icon,
|
|
2023
|
+
searchIcon: icons?.search,
|
|
2024
|
+
clearIcon: icons?.clear
|
|
1910
2025
|
}
|
|
1911
2026
|
),
|
|
1912
|
-
/* @__PURE__ */ (0,
|
|
2027
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1913
2028
|
SearchSortSelect,
|
|
1914
2029
|
{
|
|
1915
2030
|
value: search.applied.sort || "",
|
|
1916
2031
|
onChange: search.setSort,
|
|
1917
|
-
sorts: search.schema?.sorts
|
|
2032
|
+
sorts: search.schema?.sorts,
|
|
2033
|
+
className: classNames?.sort
|
|
1918
2034
|
}
|
|
1919
2035
|
)
|
|
1920
2036
|
] });
|
|
1921
|
-
const header = heading ?? /* @__PURE__ */ (0,
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
2037
|
+
const header = heading ?? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2038
|
+
SearchHeading,
|
|
2039
|
+
{
|
|
2040
|
+
total: search.total,
|
|
2041
|
+
title: headingTitle,
|
|
2042
|
+
classNames,
|
|
2043
|
+
loading: search.loading
|
|
2044
|
+
}
|
|
2045
|
+
);
|
|
2046
|
+
const stagedPanel = (items) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1926
2047
|
FilterPanel,
|
|
1927
2048
|
{
|
|
1928
2049
|
filters: items,
|
|
@@ -1933,124 +2054,88 @@ function SearchPage({
|
|
|
1933
2054
|
onRangeCommit: (id) => commitRange(id, false)
|
|
1934
2055
|
}
|
|
1935
2056
|
);
|
|
1936
|
-
|
|
2057
|
+
const sheet = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2058
|
+
FilterSheet,
|
|
2059
|
+
{
|
|
2060
|
+
open: sheetOpen,
|
|
2061
|
+
title: "Filtros",
|
|
2062
|
+
onClose: closeSheet,
|
|
2063
|
+
overlayClassName: classNames?.dialogOverlay,
|
|
2064
|
+
panelClassName: cn(classNames?.dialog, classNames?.dialogPanel),
|
|
2065
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2066
|
+
ApplyBar,
|
|
2067
|
+
{
|
|
2068
|
+
onClear: clearStagedFilters,
|
|
2069
|
+
onApply: applyStagedAndClose,
|
|
2070
|
+
className: classNames?.applyBar
|
|
2071
|
+
}
|
|
2072
|
+
),
|
|
2073
|
+
children: stagedPanel(variant === "toolbar" ? extraFilters : filters)
|
|
2074
|
+
}
|
|
2075
|
+
);
|
|
2076
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1937
2077
|
"main",
|
|
1938
2078
|
{
|
|
1939
2079
|
"data-slot": "search-page",
|
|
1940
2080
|
"data-variant": variant,
|
|
1941
|
-
className: cn(
|
|
1942
|
-
"mx-auto max-w-7xl px-6 py-12",
|
|
1943
|
-
className,
|
|
1944
|
-
classNames?.root
|
|
1945
|
-
),
|
|
2081
|
+
className: cn(className, classNames?.root),
|
|
1946
2082
|
children: [
|
|
1947
|
-
/* @__PURE__ */ (0,
|
|
1948
|
-
/* @__PURE__ */ (0,
|
|
2083
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SearchChromeStyles, {}),
|
|
2084
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: classNames?.header, children: header }),
|
|
2085
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-slot": "search-body", children: [
|
|
1949
2086
|
queryAndSort,
|
|
1950
|
-
variant === "toolbar" ? /* @__PURE__ */ (0,
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
2087
|
+
variant === "toolbar" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-slot": "search-toolbar", className: classNames?.toolbar, children: [
|
|
2088
|
+
toolbarFilters.map((filter) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2089
|
+
ToolbarPopover,
|
|
2090
|
+
{
|
|
2091
|
+
id: filter.id,
|
|
2092
|
+
label: filter.label,
|
|
2093
|
+
open: openToolbar === filter.id,
|
|
2094
|
+
onOpenChange: setOpenToolbar,
|
|
2095
|
+
triggerClassName: classNames?.toolbarTrigger,
|
|
2096
|
+
popoverClassName: classNames?.popover,
|
|
2097
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1960
2098
|
FilterPanel,
|
|
1961
2099
|
{
|
|
1962
2100
|
filters: [filter],
|
|
1963
2101
|
pathFilters: search.pathFilters,
|
|
1964
|
-
onChange:
|
|
2102
|
+
onChange: (id, value) => {
|
|
2103
|
+
search.applyFilter(id, value);
|
|
2104
|
+
if (filter.type !== "range") setOpenToolbar(null);
|
|
2105
|
+
},
|
|
1965
2106
|
rangeDraft,
|
|
1966
2107
|
onRangePatch: patchRange,
|
|
1967
|
-
onRangeCommit: (id) =>
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
extraFilters.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FiltersTrigger, { onClick: openStagedFilters }) : null
|
|
1971
|
-
]
|
|
1972
|
-
}
|
|
1973
|
-
) : null,
|
|
1974
|
-
variant === "dialog" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FiltersTrigger, { onClick: openStagedFilters }) : null,
|
|
1975
|
-
variant === "sidebar" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "grid gap-8 lg:grid-cols-[280px_minmax(0,1fr)]", children: [
|
|
1976
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1977
|
-
"aside",
|
|
1978
|
-
{
|
|
1979
|
-
"data-slot": "search-sidebar",
|
|
1980
|
-
className: cn(
|
|
1981
|
-
"hidden lg:sticky lg:top-6 lg:block lg:self-start",
|
|
1982
|
-
classNames?.sidebar
|
|
1983
|
-
),
|
|
1984
|
-
children: [
|
|
1985
|
-
stagedPanel(filters),
|
|
1986
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1987
|
-
ApplyBar,
|
|
1988
|
-
{
|
|
1989
|
-
onClear: clearStagedFilters,
|
|
1990
|
-
onApply: search.applyStaged,
|
|
1991
|
-
className: classNames?.applyBar
|
|
2108
|
+
onRangeCommit: (id, source) => {
|
|
2109
|
+
commitRange(id, true);
|
|
2110
|
+
if (source === "apply") setOpenToolbar(null);
|
|
1992
2111
|
}
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
)
|
|
2005
|
-
results
|
|
2006
|
-
] })
|
|
2007
|
-
] }) : results
|
|
2008
|
-
] }),
|
|
2009
|
-
variant !== "sidebar" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
2010
|
-
"dialog",
|
|
2011
|
-
{
|
|
2012
|
-
ref: dialogRef,
|
|
2013
|
-
className: cn(
|
|
2014
|
-
"w-[min(32rem,calc(100%-2rem))] rounded-2xl border border-border bg-background p-6 shadow-xl",
|
|
2015
|
-
classNames?.dialog
|
|
2016
|
-
),
|
|
2017
|
-
children: [
|
|
2018
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "mb-4 text-lg font-semibold", children: "Filtros" }),
|
|
2019
|
-
stagedPanel(variant === "toolbar" ? extraFilters : filters),
|
|
2020
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2112
|
+
}
|
|
2113
|
+
)
|
|
2114
|
+
},
|
|
2115
|
+
filter.id
|
|
2116
|
+
)),
|
|
2117
|
+
extraFilters.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FiltersTrigger, { onClick: openStagedFilters }) : null
|
|
2118
|
+
] }) : null,
|
|
2119
|
+
variant === "dialog" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FiltersTrigger, { onClick: openStagedFilters }) : null,
|
|
2120
|
+
variant === "sidebar" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-slot": "search-layout", children: [
|
|
2121
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("aside", { "data-slot": "search-sidebar", className: classNames?.sidebar, children: [
|
|
2122
|
+
stagedPanel(filters),
|
|
2123
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2021
2124
|
ApplyBar,
|
|
2022
2125
|
{
|
|
2023
2126
|
onClear: clearStagedFilters,
|
|
2024
|
-
onApply:
|
|
2127
|
+
onApply: search.applyStaged,
|
|
2025
2128
|
className: classNames?.applyBar
|
|
2026
2129
|
}
|
|
2027
2130
|
)
|
|
2028
|
-
]
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
"aria-label": "Fechar filtros",
|
|
2037
|
-
className: "absolute inset-0 bg-black/40",
|
|
2038
|
-
onClick: () => setMobileFiltersOpen(false)
|
|
2039
|
-
}
|
|
2040
|
-
),
|
|
2041
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "absolute inset-y-0 right-0 w-[min(22rem,100%)] overflow-y-auto bg-background p-6", children: [
|
|
2042
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "mb-4 text-lg font-semibold", children: "Filtros" }),
|
|
2043
|
-
stagedPanel(filters),
|
|
2044
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2045
|
-
ApplyBar,
|
|
2046
|
-
{
|
|
2047
|
-
onClear: clearStagedFilters,
|
|
2048
|
-
onApply: applyStagedAndClose,
|
|
2049
|
-
className: classNames?.applyBar
|
|
2050
|
-
}
|
|
2051
|
-
)
|
|
2052
|
-
] })
|
|
2053
|
-
] }) : null
|
|
2131
|
+
] }),
|
|
2132
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
|
|
2133
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FiltersTrigger, { onClick: openStagedFilters }),
|
|
2134
|
+
results
|
|
2135
|
+
] })
|
|
2136
|
+
] }) : results
|
|
2137
|
+
] }),
|
|
2138
|
+
sheet
|
|
2054
2139
|
]
|
|
2055
2140
|
}
|
|
2056
2141
|
);
|
|
@@ -2060,7 +2145,9 @@ function SearchPage({
|
|
|
2060
2145
|
FilterPanel,
|
|
2061
2146
|
ListingCard,
|
|
2062
2147
|
ResultsSkeleton,
|
|
2148
|
+
SearchChromeStyles,
|
|
2063
2149
|
SearchPage,
|
|
2150
|
+
SearchPageFallback,
|
|
2064
2151
|
SearchPagination,
|
|
2065
2152
|
SearchQueryForm,
|
|
2066
2153
|
SearchSortSelect,
|