@garagem-ai/site-sdk 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -8
- package/dist/index.d.mts +7 -58
- package/dist/index.d.ts +7 -58
- package/dist/index.js +59 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +33 -6
- package/dist/react.d.ts +33 -6
- package/dist/react.js +517 -463
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +515 -462
- package/dist/react.mjs.map +1 -1
- package/dist/{listing-card-model-D7iR4asd.d.mts → search-engine-D4EZkNrQ.d.mts} +67 -1
- package/dist/{listing-card-model-D7iR4asd.d.ts → search-engine-D4EZkNrQ.d.ts} +67 -1
- package/package.json +9 -4
- package/src/index.ts +2 -0
- package/src/presentation.ts +7 -0
- package/src/react/filter-panel.tsx +39 -42
- package/src/react/icons.tsx +46 -0
- package/src/react/index.ts +7 -1
- package/src/react/listing-card.tsx +14 -71
- package/src/react/search-chrome.tsx +24 -23
- package/src/react/search-page.tsx +210 -111
- package/src/react/search-pagination.tsx +50 -40
- package/src/react/search-query-form.tsx +31 -26
- package/src/react/search.css +717 -0
- package/src/react/styles/index.ts +1 -0
- package/src/react/styles/search-chrome-css.generated.ts +5 -0
- package/src/react/styles/search-chrome-styles.tsx +12 -0
- package/src/react/types.ts +18 -0
- package/src/react/use-public-search.ts +7 -0
- package/src/search-engine.ts +79 -0
package/dist/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") {
|
|
@@ -162,132 +170,45 @@ function ListingCard({
|
|
|
162
170
|
"article",
|
|
163
171
|
{
|
|
164
172
|
"data-slot": "listing-card",
|
|
165
|
-
className: cn(
|
|
166
|
-
"group overflow-hidden rounded-[var(--garagem-listing-card-radius,0.75rem)] border border-border bg-background",
|
|
167
|
-
className,
|
|
168
|
-
classNames?.root
|
|
169
|
-
),
|
|
173
|
+
className: cn(className, classNames?.root),
|
|
170
174
|
style,
|
|
171
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
children: [
|
|
178
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
),
|
|
210
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
211
|
-
"div",
|
|
212
|
-
{
|
|
213
|
-
"data-slot": "listing-card-body",
|
|
214
|
-
className: cn("p-4", classNames?.body),
|
|
215
|
-
children: [
|
|
216
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-baseline justify-between gap-2", children: [
|
|
217
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
218
|
-
"p",
|
|
219
|
-
{
|
|
220
|
-
"data-slot": "listing-card-price",
|
|
221
|
-
className: cn("font-semibold tracking-tight", classNames?.price),
|
|
222
|
-
style: {
|
|
223
|
-
fontSize: "var(--garagem-listing-price-size, 1.125rem)"
|
|
224
|
-
},
|
|
225
|
-
children: model.priceLabel
|
|
226
|
-
}
|
|
227
|
-
),
|
|
228
|
-
model.pricePeriod ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs text-muted-foreground", children: model.pricePeriod }) : null
|
|
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
|
|
285
|
-
]
|
|
286
|
-
}
|
|
287
|
-
)
|
|
288
|
-
]
|
|
289
|
-
}
|
|
290
|
-
)
|
|
175
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_link.default, { href: target, "data-slot": "listing-card-link", children: [
|
|
176
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { "data-slot": "listing-card-media", className: classNames?.media, children: [
|
|
177
|
+
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" })),
|
|
178
|
+
slots?.badge ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "data-slot": "listing-card-badge", className: classNames?.badge, children: model.businessLabel })
|
|
179
|
+
] }),
|
|
180
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { "data-slot": "listing-card-body", className: classNames?.body, children: [
|
|
181
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { "data-slot": "listing-card-price-row", children: [
|
|
182
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { "data-slot": "listing-card-price", className: classNames?.price, children: model.priceLabel }),
|
|
183
|
+
model.pricePeriod ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "data-slot": "listing-card-period", children: model.pricePeriod }) : null
|
|
184
|
+
] }),
|
|
185
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { "data-slot": "listing-card-title", className: classNames?.title, children: model.title }),
|
|
186
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { "data-slot": "listing-card-location", className: classNames?.location, children: model.locationLabel || model.propertyType || "" }),
|
|
187
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
188
|
+
"ul",
|
|
189
|
+
{
|
|
190
|
+
"data-slot": "listing-card-features",
|
|
191
|
+
className: classNames?.features,
|
|
192
|
+
children: [
|
|
193
|
+
model.bedrooms != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
194
|
+
model.bedrooms,
|
|
195
|
+
" quartos"
|
|
196
|
+
] }) : null,
|
|
197
|
+
model.bathrooms != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
198
|
+
model.bathrooms,
|
|
199
|
+
" banheiros"
|
|
200
|
+
] }) : null,
|
|
201
|
+
model.parkingSpaces != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
202
|
+
model.parkingSpaces,
|
|
203
|
+
" vagas"
|
|
204
|
+
] }) : null,
|
|
205
|
+
areaLabel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: areaLabel }) : null
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
),
|
|
209
|
+
slots?.cta ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-slot": "listing-card-cta", className: classNames?.cta, children: slots.cta }) : null
|
|
210
|
+
] })
|
|
211
|
+
] })
|
|
291
212
|
}
|
|
292
213
|
);
|
|
293
214
|
}
|
|
@@ -981,6 +902,54 @@ function countFacetChoices(options) {
|
|
|
981
902
|
}
|
|
982
903
|
return out;
|
|
983
904
|
}
|
|
905
|
+
var FEMININE_HEADING = /(casa|cobertura|kitnet|loja|sala|fazenda|chácara|chacara)s?$/i;
|
|
906
|
+
function pluralizePt(label) {
|
|
907
|
+
const text = label.trim();
|
|
908
|
+
if (!text || /s$/i.test(text)) return text;
|
|
909
|
+
if (/il$/i.test(text)) return `${text.slice(0, -1)}is`;
|
|
910
|
+
if (/m$/i.test(text)) return `${text.slice(0, -1)}ns`;
|
|
911
|
+
return `${text}s`;
|
|
912
|
+
}
|
|
913
|
+
function headingLocationSuffix(location) {
|
|
914
|
+
if (!location) return "";
|
|
915
|
+
if (location.street && location.neighborhood) {
|
|
916
|
+
return `${location.street}, ${location.neighborhood}`;
|
|
917
|
+
}
|
|
918
|
+
if (location.neighborhood && location.city) {
|
|
919
|
+
return `${location.neighborhood}, ${location.city}`;
|
|
920
|
+
}
|
|
921
|
+
if (location.city && location.state) {
|
|
922
|
+
return `${location.city} - ${location.state}`;
|
|
923
|
+
}
|
|
924
|
+
return location.city || location.neighborhood || location.street || location.state || "";
|
|
925
|
+
}
|
|
926
|
+
function searchResultsHeading(pathFilters, dictionary, locationNames) {
|
|
927
|
+
const types = [].concat(pathFilters.propertyType || []).filter(Boolean);
|
|
928
|
+
let noun = "Im\xF3veis";
|
|
929
|
+
let found = "encontrados";
|
|
930
|
+
if (types.length === 1) {
|
|
931
|
+
const id = String(types[0]);
|
|
932
|
+
const option = dictionary?.propertyTypes?.find(
|
|
933
|
+
(entry) => entry.id === id || entry.slug === id
|
|
934
|
+
);
|
|
935
|
+
const label = option?.label;
|
|
936
|
+
if (label) {
|
|
937
|
+
noun = pluralizePt(label.charAt(0).toUpperCase() + label.slice(1));
|
|
938
|
+
if (FEMININE_HEADING.test(id) || FEMININE_HEADING.test(label)) {
|
|
939
|
+
found = "encontradas";
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
const place = locationNames ? headingLocationSuffix(
|
|
944
|
+
displayPathLocation(pathFilters.location, locationNames)
|
|
945
|
+
) : "";
|
|
946
|
+
if (place) return `${noun} ${found} em ${place}`;
|
|
947
|
+
return `${noun} ${found}`;
|
|
948
|
+
}
|
|
949
|
+
function hrefWithExplicitPage(href, page) {
|
|
950
|
+
if (page !== 1 || /(?:\?|&)page=/.test(href)) return href;
|
|
951
|
+
return href.includes("?") ? `${href}&page=1` : `${href}?page=1`;
|
|
952
|
+
}
|
|
984
953
|
function paginationPages(currentPage, totalPages, padding) {
|
|
985
954
|
if (totalPages < 1) return [];
|
|
986
955
|
const current = Math.min(Math.max(1, currentPage), totalPages);
|
|
@@ -1004,10 +973,9 @@ function RangeFields({
|
|
|
1004
973
|
const patch = (side, raw) => {
|
|
1005
974
|
onRangePatch(filter.id, side, isPrice ? formatGroupedInteger(raw) : raw);
|
|
1006
975
|
};
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.
|
|
1010
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex gap-2", children: [
|
|
976
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("fieldset", { "data-slot": "search-filter", children: [
|
|
977
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("legend", { children: filter.label }),
|
|
978
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-slot": "search-range-row", children: [
|
|
1011
979
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1012
980
|
RangeSide,
|
|
1013
981
|
{
|
|
@@ -1015,9 +983,9 @@ function RangeFields({
|
|
|
1015
983
|
label: "M\xEDn",
|
|
1016
984
|
isPrice,
|
|
1017
985
|
value: draft.min,
|
|
1018
|
-
inputClass,
|
|
1019
986
|
onPatch: (raw) => patch("min", raw),
|
|
1020
|
-
onCommit: () => onRangeCommit(filter.id)
|
|
987
|
+
onCommit: () => onRangeCommit(filter.id, "blur"),
|
|
988
|
+
onEnter: () => onRangeCommit(filter.id, "enter")
|
|
1021
989
|
}
|
|
1022
990
|
),
|
|
1023
991
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -1027,9 +995,18 @@ function RangeFields({
|
|
|
1027
995
|
label: "M\xE1x",
|
|
1028
996
|
isPrice,
|
|
1029
997
|
value: draft.max,
|
|
1030
|
-
inputClass,
|
|
1031
998
|
onPatch: (raw) => patch("max", raw),
|
|
1032
|
-
onCommit: () => onRangeCommit(filter.id)
|
|
999
|
+
onCommit: () => onRangeCommit(filter.id, "blur"),
|
|
1000
|
+
onEnter: () => onRangeCommit(filter.id, "enter")
|
|
1001
|
+
}
|
|
1002
|
+
),
|
|
1003
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1004
|
+
"button",
|
|
1005
|
+
{
|
|
1006
|
+
type: "button",
|
|
1007
|
+
"data-slot": "search-range-apply",
|
|
1008
|
+
onClick: () => onRangeCommit(filter.id, "apply"),
|
|
1009
|
+
children: "Atualizar"
|
|
1033
1010
|
}
|
|
1034
1011
|
)
|
|
1035
1012
|
] })
|
|
@@ -1040,9 +1017,9 @@ function RangeSide({
|
|
|
1040
1017
|
label,
|
|
1041
1018
|
isPrice,
|
|
1042
1019
|
value,
|
|
1043
|
-
inputClass,
|
|
1044
1020
|
onPatch,
|
|
1045
|
-
onCommit
|
|
1021
|
+
onCommit,
|
|
1022
|
+
onEnter
|
|
1046
1023
|
}) {
|
|
1047
1024
|
const input = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1048
1025
|
"input",
|
|
@@ -1057,15 +1034,18 @@ function RangeSide({
|
|
|
1057
1034
|
onChange: (event) => onPatch(event.target.value),
|
|
1058
1035
|
onBlur: onCommit,
|
|
1059
1036
|
onKeyDown: (event) => {
|
|
1060
|
-
if (event.key === "Enter")
|
|
1037
|
+
if (event.key === "Enter") {
|
|
1038
|
+
event.preventDefault();
|
|
1039
|
+
onEnter();
|
|
1040
|
+
}
|
|
1061
1041
|
},
|
|
1062
|
-
|
|
1042
|
+
"data-slot": "search-range-input"
|
|
1063
1043
|
}
|
|
1064
1044
|
);
|
|
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", {
|
|
1045
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { "data-slot": "search-range-side", htmlFor: id, children: [
|
|
1046
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: label }),
|
|
1047
|
+
isPrice ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { "data-slot": "search-range-affix", children: [
|
|
1048
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-slot": "search-range-prefix", children: "R$" }),
|
|
1069
1049
|
input
|
|
1070
1050
|
] }) : input
|
|
1071
1051
|
] });
|
|
@@ -1077,17 +1057,15 @@ function CountFields({
|
|
|
1077
1057
|
}) {
|
|
1078
1058
|
const selected = pathFilterValue(pathFilters, filter.id);
|
|
1079
1059
|
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", {
|
|
1060
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("fieldset", { "data-slot": "search-filter", children: [
|
|
1061
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("legend", { children: filter.label }),
|
|
1062
|
+
/* @__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
1063
|
"button",
|
|
1084
1064
|
{
|
|
1085
1065
|
type: "button",
|
|
1066
|
+
"data-slot": "search-count-choice",
|
|
1067
|
+
"data-selected": selected === choice.id ? "true" : void 0,
|
|
1086
1068
|
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
1069
|
children: choice.label
|
|
1092
1070
|
},
|
|
1093
1071
|
choice.id
|
|
@@ -1101,36 +1079,20 @@ function EnumFields({
|
|
|
1101
1079
|
}) {
|
|
1102
1080
|
const options = filter.options || [];
|
|
1103
1081
|
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
|
-
)
|
|
1082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("fieldset", { "data-slot": "search-filter", children: [
|
|
1083
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("legend", { children: filter.label }),
|
|
1084
|
+
/* @__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: [
|
|
1085
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1086
|
+
"input",
|
|
1087
|
+
{
|
|
1088
|
+
type: "checkbox",
|
|
1089
|
+
"data-slot": "search-checkbox",
|
|
1090
|
+
checked: pathFilterHasOption(pathFilters, filter.id, option.id),
|
|
1091
|
+
onChange: () => onChange(filter.id, option.id)
|
|
1092
|
+
}
|
|
1093
|
+
),
|
|
1094
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: option.label })
|
|
1095
|
+
] }, option.id)) })
|
|
1134
1096
|
] });
|
|
1135
1097
|
}
|
|
1136
1098
|
function FilterPanel({
|
|
@@ -1141,7 +1103,7 @@ function FilterPanel({
|
|
|
1141
1103
|
onRangePatch,
|
|
1142
1104
|
onRangeCommit
|
|
1143
1105
|
}) {
|
|
1144
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", {
|
|
1106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-slot": "search-filters", children: filters.map((filter) => {
|
|
1145
1107
|
if (filter.type === "range") {
|
|
1146
1108
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1147
1109
|
RangeFields,
|
|
@@ -1191,8 +1153,19 @@ function rangeDraftFromPath(pathFilters) {
|
|
|
1191
1153
|
};
|
|
1192
1154
|
}
|
|
1193
1155
|
|
|
1194
|
-
// src/react/search-chrome.
|
|
1156
|
+
// src/react/styles/search-chrome-css.generated.ts
|
|
1157
|
+
var SEARCH_CHROME_CSS_VERSION = "0.4.1";
|
|
1158
|
+
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}}`;
|
|
1159
|
+
|
|
1160
|
+
// src/react/styles/search-chrome-styles.tsx
|
|
1195
1161
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1162
|
+
var STYLE_ID = `garagem-search-chrome-${SEARCH_CHROME_CSS_VERSION}`;
|
|
1163
|
+
function SearchChromeStyles() {
|
|
1164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { id: STYLE_ID, children: SEARCH_CHROME_CSS });
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
// src/react/search-chrome.tsx
|
|
1168
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1196
1169
|
function SearchSortSelect({
|
|
1197
1170
|
value,
|
|
1198
1171
|
onChange,
|
|
@@ -1200,16 +1173,16 @@ function SearchSortSelect({
|
|
|
1200
1173
|
className
|
|
1201
1174
|
}) {
|
|
1202
1175
|
const options = searchSortOptions(sorts);
|
|
1203
|
-
return /* @__PURE__ */ (0,
|
|
1204
|
-
/* @__PURE__ */ (0,
|
|
1205
|
-
/* @__PURE__ */ (0,
|
|
1176
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { "data-slot": "search-sort", className, children: [
|
|
1177
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-slot": "search-label", children: "Ordenar" }),
|
|
1178
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1206
1179
|
"select",
|
|
1207
1180
|
{
|
|
1208
1181
|
id: "garagem-search-sort",
|
|
1182
|
+
"data-slot": "search-sort-trigger",
|
|
1209
1183
|
value,
|
|
1210
1184
|
onChange: (event) => onChange(event.target.value || null),
|
|
1211
|
-
|
|
1212
|
-
children: options.map((sort) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: sort.id, children: sort.label }, sort.id || "relevance"))
|
|
1185
|
+
children: options.map((sort) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: sort.id, children: sort.label }, sort.id || "relevance"))
|
|
1213
1186
|
}
|
|
1214
1187
|
)
|
|
1215
1188
|
] });
|
|
@@ -1217,127 +1190,118 @@ function SearchSortSelect({
|
|
|
1217
1190
|
function ResultsSkeleton({
|
|
1218
1191
|
className
|
|
1219
1192
|
}) {
|
|
1220
|
-
return /* @__PURE__ */ (0,
|
|
1221
|
-
"div",
|
|
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
|
-
);
|
|
1193
|
+
return /* @__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: [
|
|
1194
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "media" }),
|
|
1195
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-slot": "search-skeleton-body", children: [
|
|
1196
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "line-lg" }),
|
|
1197
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "line-md" }),
|
|
1198
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "line-sm" })
|
|
1199
|
+
] })
|
|
1200
|
+
] }, i)) });
|
|
1201
|
+
}
|
|
1202
|
+
function SearchPageFallback({
|
|
1203
|
+
className
|
|
1204
|
+
}) {
|
|
1205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("main", { "data-slot": "search-page", children: [
|
|
1206
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SearchChromeStyles, {}),
|
|
1207
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ResultsSkeleton, { className })
|
|
1208
|
+
] });
|
|
1251
1209
|
}
|
|
1252
1210
|
|
|
1253
1211
|
// src/react/search-pagination.tsx
|
|
1254
1212
|
var import_link2 = __toESM(require("next/link"));
|
|
1255
|
-
var
|
|
1213
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1256
1214
|
function NavItem({
|
|
1257
1215
|
href,
|
|
1258
1216
|
label,
|
|
1259
1217
|
disabled,
|
|
1260
1218
|
current,
|
|
1261
|
-
|
|
1219
|
+
onNavigate
|
|
1262
1220
|
}) {
|
|
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
1221
|
if (disabled || !href || current) {
|
|
1270
|
-
return /* @__PURE__ */ (0,
|
|
1222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1223
|
+
"li",
|
|
1224
|
+
{
|
|
1225
|
+
"data-slot": "search-pagination-item",
|
|
1226
|
+
"data-current": current ? "true" : void 0,
|
|
1227
|
+
"data-disabled": disabled ? "true" : void 0,
|
|
1228
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: label })
|
|
1229
|
+
}
|
|
1230
|
+
);
|
|
1271
1231
|
}
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
{
|
|
1275
|
-
|
|
1276
|
-
className: "flex size-full items-center justify-center",
|
|
1277
|
-
"aria-label": label,
|
|
1278
|
-
children: label
|
|
1232
|
+
function handleClick(event) {
|
|
1233
|
+
if (!onNavigate || !href) return;
|
|
1234
|
+
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0) {
|
|
1235
|
+
return;
|
|
1279
1236
|
}
|
|
1280
|
-
|
|
1237
|
+
event.preventDefault();
|
|
1238
|
+
onNavigate(href);
|
|
1239
|
+
}
|
|
1240
|
+
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 }) });
|
|
1281
1241
|
}
|
|
1282
1242
|
function SearchPagination({
|
|
1283
1243
|
page,
|
|
1284
1244
|
totalPages,
|
|
1285
1245
|
hrefForPage,
|
|
1246
|
+
onNavigate,
|
|
1286
1247
|
className
|
|
1287
1248
|
}) {
|
|
1288
1249
|
if (totalPages <= 1) return null;
|
|
1289
|
-
const
|
|
1290
|
-
|
|
1291
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1250
|
+
const pages = paginationPages(page, totalPages, 2);
|
|
1251
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1292
1252
|
"nav",
|
|
1293
1253
|
{
|
|
1294
1254
|
"data-slot": "search-pagination",
|
|
1295
|
-
className
|
|
1255
|
+
className,
|
|
1296
1256
|
"aria-label": "Pagina\xE7\xE3o",
|
|
1297
|
-
children: /* @__PURE__ */ (0,
|
|
1298
|
-
/* @__PURE__ */ (0,
|
|
1299
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1257
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("ul", { children: [
|
|
1258
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1300
1259
|
NavItem,
|
|
1301
1260
|
{
|
|
1302
|
-
href: hrefForPage(
|
|
1303
|
-
label: "\u2039",
|
|
1304
|
-
disabled: page <= 1
|
|
1261
|
+
href: hrefWithExplicitPage(hrefForPage(1), 1),
|
|
1262
|
+
label: "\u2039\u2039",
|
|
1263
|
+
disabled: page <= 1,
|
|
1264
|
+
onNavigate
|
|
1305
1265
|
}
|
|
1306
1266
|
),
|
|
1307
|
-
|
|
1267
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1308
1268
|
NavItem,
|
|
1309
1269
|
{
|
|
1310
|
-
href:
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1270
|
+
href: hrefWithExplicitPage(
|
|
1271
|
+
hrefForPage(Math.max(1, page - 1)),
|
|
1272
|
+
Math.max(1, page - 1)
|
|
1273
|
+
),
|
|
1274
|
+
label: "\u2039",
|
|
1275
|
+
disabled: page <= 1,
|
|
1276
|
+
onNavigate
|
|
1277
|
+
}
|
|
1278
|
+
),
|
|
1279
|
+
pages.map((n) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1318
1280
|
NavItem,
|
|
1319
1281
|
{
|
|
1320
|
-
href: hrefForPage(n),
|
|
1282
|
+
href: hrefWithExplicitPage(hrefForPage(n), n),
|
|
1321
1283
|
label: String(n),
|
|
1322
1284
|
current: n === page,
|
|
1323
|
-
|
|
1285
|
+
onNavigate
|
|
1324
1286
|
},
|
|
1325
|
-
|
|
1287
|
+
n
|
|
1326
1288
|
)),
|
|
1327
|
-
/* @__PURE__ */ (0,
|
|
1289
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1328
1290
|
NavItem,
|
|
1329
1291
|
{
|
|
1330
1292
|
href: hrefForPage(Math.min(totalPages, page + 1)),
|
|
1331
1293
|
label: "\u203A",
|
|
1332
|
-
disabled: page >= totalPages
|
|
1294
|
+
disabled: page >= totalPages,
|
|
1295
|
+
onNavigate
|
|
1333
1296
|
}
|
|
1334
1297
|
),
|
|
1335
|
-
/* @__PURE__ */ (0,
|
|
1298
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1336
1299
|
NavItem,
|
|
1337
1300
|
{
|
|
1338
1301
|
href: hrefForPage(totalPages),
|
|
1339
1302
|
label: "\u203A\u203A",
|
|
1340
|
-
disabled: page >= totalPages
|
|
1303
|
+
disabled: page >= totalPages,
|
|
1304
|
+
onNavigate
|
|
1341
1305
|
}
|
|
1342
1306
|
)
|
|
1343
1307
|
] })
|
|
@@ -1345,73 +1309,102 @@ function SearchPagination({
|
|
|
1345
1309
|
);
|
|
1346
1310
|
}
|
|
1347
1311
|
|
|
1312
|
+
// src/react/icons.tsx
|
|
1313
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1314
|
+
function Icon({ children, ...props }) {
|
|
1315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1316
|
+
"svg",
|
|
1317
|
+
{
|
|
1318
|
+
viewBox: "0 0 24 24",
|
|
1319
|
+
fill: "none",
|
|
1320
|
+
stroke: "currentColor",
|
|
1321
|
+
strokeWidth: 2,
|
|
1322
|
+
strokeLinecap: "round",
|
|
1323
|
+
strokeLinejoin: "round",
|
|
1324
|
+
"aria-hidden": true,
|
|
1325
|
+
"data-slot": "search-icon",
|
|
1326
|
+
...props,
|
|
1327
|
+
children
|
|
1328
|
+
}
|
|
1329
|
+
);
|
|
1330
|
+
}
|
|
1331
|
+
function SearchLensIcon(props) {
|
|
1332
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Icon, { ...props, children: [
|
|
1333
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("circle", { cx: "11", cy: "11", r: "7" }),
|
|
1334
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M20 20l-3.5-3.5" })
|
|
1335
|
+
] });
|
|
1336
|
+
}
|
|
1337
|
+
function SearchClearIcon(props) {
|
|
1338
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M6 6l12 12M18 6L6 18" }) });
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1348
1341
|
// src/react/search-query-form.tsx
|
|
1349
|
-
var
|
|
1342
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1350
1343
|
function SearchQueryForm({
|
|
1351
1344
|
value,
|
|
1352
1345
|
onChange,
|
|
1353
1346
|
onSubmit,
|
|
1354
1347
|
onClear,
|
|
1355
|
-
className
|
|
1348
|
+
className,
|
|
1349
|
+
iconClassName,
|
|
1350
|
+
searchIcon,
|
|
1351
|
+
clearIcon
|
|
1356
1352
|
}) {
|
|
1357
1353
|
function handleSubmit(event) {
|
|
1358
1354
|
event.preventDefault();
|
|
1359
1355
|
onSubmit();
|
|
1360
1356
|
}
|
|
1361
|
-
return /* @__PURE__ */ (0,
|
|
1357
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1362
1358
|
"form",
|
|
1363
1359
|
{
|
|
1364
1360
|
role: "search",
|
|
1365
1361
|
"data-slot": "search-query",
|
|
1366
1362
|
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)(
|
|
1363
|
+
className,
|
|
1364
|
+
children: [
|
|
1365
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: "garagem-search-q", "data-slot": "search-label", children: "Busca" }),
|
|
1366
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-slot": "search-query-field", children: [
|
|
1367
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1379
1368
|
"input",
|
|
1380
1369
|
{
|
|
1381
1370
|
id: "garagem-search-q",
|
|
1382
1371
|
name: "q",
|
|
1383
|
-
type: "
|
|
1372
|
+
type: "text",
|
|
1373
|
+
inputMode: "search",
|
|
1384
1374
|
autoComplete: "off",
|
|
1385
1375
|
enterKeyHint: "search",
|
|
1386
1376
|
value,
|
|
1387
1377
|
onChange: (event) => onChange(event.target.value),
|
|
1388
1378
|
placeholder: "Busque por bairro, rua ou c\xF3digo",
|
|
1389
|
-
|
|
1379
|
+
"data-slot": "search-query-input"
|
|
1390
1380
|
}
|
|
1391
1381
|
),
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1382
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-slot": "search-query-actions", children: [
|
|
1383
|
+
value ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1384
|
+
"button",
|
|
1385
|
+
{
|
|
1386
|
+
type: "button",
|
|
1387
|
+
title: "Limpar busca",
|
|
1388
|
+
"aria-label": "Limpar busca",
|
|
1389
|
+
onClick: onClear,
|
|
1390
|
+
"data-slot": "search-icon-button",
|
|
1391
|
+
"data-kind": "clear",
|
|
1392
|
+
children: clearIcon ?? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SearchClearIcon, { className: iconClassName })
|
|
1393
|
+
}
|
|
1394
|
+
) : null,
|
|
1395
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1396
|
+
"button",
|
|
1397
|
+
{
|
|
1398
|
+
type: "submit",
|
|
1399
|
+
title: "Buscar",
|
|
1400
|
+
"aria-label": "Buscar",
|
|
1401
|
+
"data-slot": "search-icon-button",
|
|
1402
|
+
children: searchIcon ?? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SearchLensIcon, { className: iconClassName })
|
|
1403
|
+
}
|
|
1404
|
+
)
|
|
1405
|
+
] })
|
|
1413
1406
|
] })
|
|
1414
|
-
]
|
|
1407
|
+
]
|
|
1415
1408
|
}
|
|
1416
1409
|
);
|
|
1417
1410
|
}
|
|
@@ -1515,6 +1508,9 @@ function usePublicSearch(options) {
|
|
|
1515
1508
|
const [loading, setLoading] = (0, import_react.useState)(true);
|
|
1516
1509
|
const [qDraft, setQDraft] = (0, import_react.useState)("");
|
|
1517
1510
|
const [staged, setStaged] = (0, import_react.useState)({});
|
|
1511
|
+
const [locationNames, setLocationNames] = (0, import_react.useState)(
|
|
1512
|
+
null
|
|
1513
|
+
);
|
|
1518
1514
|
const parsed = (0, import_react.useMemo)(
|
|
1519
1515
|
() => readPublicSearch(pathname, search, schema?.dictionary),
|
|
1520
1516
|
[pathname, search, schema?.dictionary]
|
|
@@ -1558,6 +1554,7 @@ function usePublicSearch(options) {
|
|
|
1558
1554
|
const id = catalogId;
|
|
1559
1555
|
let active = true;
|
|
1560
1556
|
locationsRef.current = null;
|
|
1557
|
+
setLocationNames(null);
|
|
1561
1558
|
setSchema(null);
|
|
1562
1559
|
setListings([]);
|
|
1563
1560
|
setLoading(true);
|
|
@@ -1580,10 +1577,12 @@ function usePublicSearch(options) {
|
|
|
1580
1577
|
}
|
|
1581
1578
|
if (!active) return;
|
|
1582
1579
|
locationsRef.current = locations;
|
|
1580
|
+
setLocationNames(locations);
|
|
1583
1581
|
setSchema(nextSchema);
|
|
1584
1582
|
} catch {
|
|
1585
1583
|
if (active) {
|
|
1586
1584
|
locationsRef.current = null;
|
|
1585
|
+
setLocationNames(null);
|
|
1587
1586
|
setSchema(null);
|
|
1588
1587
|
setLoading(false);
|
|
1589
1588
|
}
|
|
@@ -1733,44 +1732,75 @@ function usePublicSearch(options) {
|
|
|
1733
1732
|
clearQuery,
|
|
1734
1733
|
setSort,
|
|
1735
1734
|
hrefForPage,
|
|
1736
|
-
go
|
|
1735
|
+
go,
|
|
1736
|
+
locationNames
|
|
1737
1737
|
};
|
|
1738
1738
|
}
|
|
1739
1739
|
|
|
1740
1740
|
// src/react/search-page.tsx
|
|
1741
|
-
var
|
|
1741
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1742
1742
|
function ToolbarPopover({
|
|
1743
|
+
id,
|
|
1743
1744
|
label,
|
|
1745
|
+
open,
|
|
1746
|
+
onOpenChange,
|
|
1747
|
+
triggerClassName,
|
|
1748
|
+
popoverClassName,
|
|
1744
1749
|
children
|
|
1745
1750
|
}) {
|
|
1746
|
-
const
|
|
1747
|
-
|
|
1748
|
-
|
|
1751
|
+
const rootRef = (0, import_react2.useRef)(null);
|
|
1752
|
+
(0, import_react2.useEffect)(() => {
|
|
1753
|
+
if (!open) return;
|
|
1754
|
+
function onPointer(event) {
|
|
1755
|
+
if (!rootRef.current?.contains(event.target)) {
|
|
1756
|
+
onOpenChange(null);
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
function onKey(event) {
|
|
1760
|
+
if (event.key === "Escape") onOpenChange(null);
|
|
1761
|
+
}
|
|
1762
|
+
document.addEventListener("mousedown", onPointer);
|
|
1763
|
+
document.addEventListener("keydown", onKey);
|
|
1764
|
+
return () => {
|
|
1765
|
+
document.removeEventListener("mousedown", onPointer);
|
|
1766
|
+
document.removeEventListener("keydown", onKey);
|
|
1767
|
+
};
|
|
1768
|
+
}, [open, onOpenChange]);
|
|
1769
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-toolbar-item", ref: rootRef, children: [
|
|
1770
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1749
1771
|
"button",
|
|
1750
1772
|
{
|
|
1751
1773
|
type: "button",
|
|
1752
|
-
|
|
1753
|
-
className:
|
|
1774
|
+
"data-slot": "search-toolbar-trigger",
|
|
1775
|
+
className: triggerClassName,
|
|
1776
|
+
"aria-expanded": open,
|
|
1777
|
+
onClick: () => onOpenChange(open ? null : id),
|
|
1754
1778
|
children: label
|
|
1755
1779
|
}
|
|
1756
1780
|
),
|
|
1757
|
-
open ? /* @__PURE__ */ (0,
|
|
1781
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1782
|
+
"div",
|
|
1783
|
+
{
|
|
1784
|
+
"data-slot": "search-popover",
|
|
1785
|
+
className: popoverClassName,
|
|
1786
|
+
role: "dialog",
|
|
1787
|
+
children
|
|
1788
|
+
}
|
|
1789
|
+
) : null
|
|
1758
1790
|
] });
|
|
1759
1791
|
}
|
|
1760
1792
|
function FiltersTrigger({
|
|
1761
1793
|
onClick,
|
|
1762
1794
|
className
|
|
1763
1795
|
}) {
|
|
1764
|
-
return /* @__PURE__ */ (0,
|
|
1796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1765
1797
|
"button",
|
|
1766
1798
|
{
|
|
1767
1799
|
type: "button",
|
|
1768
1800
|
title: "Filtros",
|
|
1801
|
+
"data-slot": "search-filters-trigger",
|
|
1769
1802
|
onClick,
|
|
1770
|
-
className
|
|
1771
|
-
"min-h-10 cursor-pointer rounded-lg border border-border px-3 text-sm hover:bg-muted",
|
|
1772
|
-
className
|
|
1773
|
-
),
|
|
1803
|
+
className,
|
|
1774
1804
|
children: "Filtros"
|
|
1775
1805
|
}
|
|
1776
1806
|
);
|
|
@@ -1780,27 +1810,82 @@ function ApplyBar({
|
|
|
1780
1810
|
onApply,
|
|
1781
1811
|
className
|
|
1782
1812
|
}) {
|
|
1783
|
-
return /* @__PURE__ */ (0,
|
|
1784
|
-
/* @__PURE__ */ (0,
|
|
1813
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-apply-bar", className, children: [
|
|
1814
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "data-kind": "clear", onClick: onClear, children: "Limpar" }),
|
|
1815
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "data-kind": "apply", onClick: onApply, children: "Ver resultados" })
|
|
1816
|
+
] });
|
|
1817
|
+
}
|
|
1818
|
+
function FilterSheet({
|
|
1819
|
+
open,
|
|
1820
|
+
title,
|
|
1821
|
+
onClose,
|
|
1822
|
+
overlayClassName,
|
|
1823
|
+
panelClassName,
|
|
1824
|
+
children,
|
|
1825
|
+
footer
|
|
1826
|
+
}) {
|
|
1827
|
+
const onCloseRef = (0, import_react2.useRef)(onClose);
|
|
1828
|
+
onCloseRef.current = onClose;
|
|
1829
|
+
(0, import_react2.useEffect)(() => {
|
|
1830
|
+
if (!open) return;
|
|
1831
|
+
function onKey(event) {
|
|
1832
|
+
if (event.key === "Escape") onCloseRef.current();
|
|
1833
|
+
}
|
|
1834
|
+
document.addEventListener("keydown", onKey);
|
|
1835
|
+
const previous = document.body.style.overflow;
|
|
1836
|
+
document.body.style.overflow = "hidden";
|
|
1837
|
+
return () => {
|
|
1838
|
+
document.removeEventListener("keydown", onKey);
|
|
1839
|
+
document.body.style.overflow = previous;
|
|
1840
|
+
};
|
|
1841
|
+
}, [open]);
|
|
1842
|
+
if (!open) return null;
|
|
1843
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-sheet", children: [
|
|
1844
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1785
1845
|
"button",
|
|
1786
1846
|
{
|
|
1787
1847
|
type: "button",
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1848
|
+
"aria-label": "Fechar filtros",
|
|
1849
|
+
"data-slot": "search-sheet-overlay",
|
|
1850
|
+
className: overlayClassName,
|
|
1851
|
+
onClick: onClose
|
|
1791
1852
|
}
|
|
1792
1853
|
),
|
|
1793
|
-
/* @__PURE__ */ (0,
|
|
1794
|
-
"
|
|
1854
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1855
|
+
"div",
|
|
1795
1856
|
{
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1857
|
+
"data-slot": "search-sheet-panel",
|
|
1858
|
+
className: panelClassName,
|
|
1859
|
+
role: "dialog",
|
|
1860
|
+
"aria-modal": "true",
|
|
1861
|
+
"aria-label": title,
|
|
1862
|
+
children: [
|
|
1863
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { "data-slot": "search-sheet-title", children: title }),
|
|
1864
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "data-slot": "search-sheet-body", children }),
|
|
1865
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "data-slot": "search-sheet-footer", children: footer })
|
|
1866
|
+
]
|
|
1800
1867
|
}
|
|
1801
1868
|
)
|
|
1802
1869
|
] });
|
|
1803
1870
|
}
|
|
1871
|
+
function SearchHeading({
|
|
1872
|
+
total,
|
|
1873
|
+
title,
|
|
1874
|
+
classNames,
|
|
1875
|
+
loading
|
|
1876
|
+
}) {
|
|
1877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-heading", className: classNames?.heading, children: [
|
|
1878
|
+
!loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1879
|
+
"span",
|
|
1880
|
+
{
|
|
1881
|
+
"data-slot": "search-heading-count",
|
|
1882
|
+
className: classNames?.headingCount,
|
|
1883
|
+
children: total.toLocaleString("pt-BR")
|
|
1884
|
+
}
|
|
1885
|
+
) : null,
|
|
1886
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h1", { "data-slot": "search-heading-title", className: classNames?.headingTitle, children: title })
|
|
1887
|
+
] });
|
|
1888
|
+
}
|
|
1804
1889
|
function SearchPage({
|
|
1805
1890
|
siteId,
|
|
1806
1891
|
baseUrl,
|
|
@@ -1808,11 +1893,12 @@ function SearchPage({
|
|
|
1808
1893
|
className,
|
|
1809
1894
|
classNames,
|
|
1810
1895
|
heading,
|
|
1896
|
+
icons,
|
|
1811
1897
|
listingCard: Card = ListingCard
|
|
1812
1898
|
}) {
|
|
1813
1899
|
const search = usePublicSearch({ siteId, baseUrl });
|
|
1814
|
-
const
|
|
1815
|
-
const [
|
|
1900
|
+
const [sheetOpen, setSheetOpen] = (0, import_react2.useState)(false);
|
|
1901
|
+
const [openToolbar, setOpenToolbar] = (0, import_react2.useState)(null);
|
|
1816
1902
|
const [rangeDraft, setRangeDraft] = (0, import_react2.useState)(
|
|
1817
1903
|
() => rangeDraftFromPath(search.pathFilters)
|
|
1818
1904
|
);
|
|
@@ -1823,6 +1909,11 @@ function SearchPage({
|
|
|
1823
1909
|
const toolbarIds = new Set(toolbarFilterIds(search.schema));
|
|
1824
1910
|
const toolbarFilters = filters.filter((filter) => toolbarIds.has(filter.id));
|
|
1825
1911
|
const extraFilters = filters.filter((filter) => !toolbarIds.has(filter.id));
|
|
1912
|
+
const headingTitle = searchResultsHeading(
|
|
1913
|
+
search.pathFilters,
|
|
1914
|
+
search.schema?.dictionary,
|
|
1915
|
+
search.locationNames
|
|
1916
|
+
);
|
|
1826
1917
|
function patchRange(filterId, side, value) {
|
|
1827
1918
|
setRangeDraft((prev) => ({
|
|
1828
1919
|
...prev,
|
|
@@ -1841,9 +1932,12 @@ function SearchPage({
|
|
|
1841
1932
|
function openStagedFilters() {
|
|
1842
1933
|
search.resetStagedFromUrl();
|
|
1843
1934
|
setRangeDraft(rangeDraftFromPath(search.pathFilters));
|
|
1844
|
-
|
|
1845
|
-
|
|
1935
|
+
setOpenToolbar(null);
|
|
1936
|
+
setSheetOpen(true);
|
|
1846
1937
|
}
|
|
1938
|
+
const closeSheet = (0, import_react2.useCallback)(() => {
|
|
1939
|
+
setSheetOpen(false);
|
|
1940
|
+
}, []);
|
|
1847
1941
|
function clearStagedFilters() {
|
|
1848
1942
|
const keepIds = variant === "toolbar" ? [...toolbarIds] : [];
|
|
1849
1943
|
const source = variant === "toolbar" ? search.pathFilters : search.staged;
|
|
@@ -1861,68 +1955,62 @@ function SearchPage({
|
|
|
1861
1955
|
}
|
|
1862
1956
|
function applyStagedAndClose() {
|
|
1863
1957
|
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",
|
|
1958
|
+
closeSheet();
|
|
1959
|
+
}
|
|
1960
|
+
const results = search.loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ResultsSkeleton, { className: classNames?.skeleton ?? classNames?.grid }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
1961
|
+
/* @__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)(
|
|
1962
|
+
Card,
|
|
1875
1963
|
{
|
|
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)(
|
|
1964
|
+
listing,
|
|
1965
|
+
className: classNames?.card
|
|
1966
|
+
},
|
|
1967
|
+
listing.id
|
|
1968
|
+
)) }),
|
|
1969
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1892
1970
|
SearchPagination,
|
|
1893
1971
|
{
|
|
1894
1972
|
page: search.page,
|
|
1895
1973
|
totalPages: search.totalPages,
|
|
1896
1974
|
hrefForPage: search.hrefForPage,
|
|
1975
|
+
onNavigate: search.go,
|
|
1897
1976
|
className: classNames?.pagination
|
|
1898
1977
|
}
|
|
1899
1978
|
)
|
|
1900
1979
|
] });
|
|
1901
|
-
const queryAndSort = /* @__PURE__ */ (0,
|
|
1902
|
-
/* @__PURE__ */ (0,
|
|
1980
|
+
const queryAndSort = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-query-sort", children: [
|
|
1981
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1903
1982
|
SearchQueryForm,
|
|
1904
1983
|
{
|
|
1905
1984
|
value: search.qDraft,
|
|
1906
1985
|
onChange: search.setQDraft,
|
|
1907
1986
|
onSubmit: search.submitQuery,
|
|
1908
1987
|
onClear: search.clearQuery,
|
|
1909
|
-
className:
|
|
1988
|
+
className: classNames?.query,
|
|
1989
|
+
iconClassName: classNames?.icon,
|
|
1990
|
+
searchIcon: icons?.search,
|
|
1991
|
+
clearIcon: icons?.clear
|
|
1910
1992
|
}
|
|
1911
1993
|
),
|
|
1912
|
-
/* @__PURE__ */ (0,
|
|
1994
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1913
1995
|
SearchSortSelect,
|
|
1914
1996
|
{
|
|
1915
1997
|
value: search.applied.sort || "",
|
|
1916
1998
|
onChange: search.setSort,
|
|
1917
|
-
sorts: search.schema?.sorts
|
|
1999
|
+
sorts: search.schema?.sorts,
|
|
2000
|
+
className: classNames?.sort
|
|
1918
2001
|
}
|
|
1919
2002
|
)
|
|
1920
2003
|
] });
|
|
1921
|
-
const header = heading ?? /* @__PURE__ */ (0,
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
2004
|
+
const header = heading ?? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2005
|
+
SearchHeading,
|
|
2006
|
+
{
|
|
2007
|
+
total: search.total,
|
|
2008
|
+
title: headingTitle,
|
|
2009
|
+
classNames,
|
|
2010
|
+
loading: search.loading
|
|
2011
|
+
}
|
|
2012
|
+
);
|
|
2013
|
+
const stagedPanel = (items) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1926
2014
|
FilterPanel,
|
|
1927
2015
|
{
|
|
1928
2016
|
filters: items,
|
|
@@ -1933,124 +2021,88 @@ function SearchPage({
|
|
|
1933
2021
|
onRangeCommit: (id) => commitRange(id, false)
|
|
1934
2022
|
}
|
|
1935
2023
|
);
|
|
1936
|
-
|
|
2024
|
+
const sheet = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2025
|
+
FilterSheet,
|
|
2026
|
+
{
|
|
2027
|
+
open: sheetOpen,
|
|
2028
|
+
title: "Filtros",
|
|
2029
|
+
onClose: closeSheet,
|
|
2030
|
+
overlayClassName: classNames?.dialogOverlay,
|
|
2031
|
+
panelClassName: cn(classNames?.dialog, classNames?.dialogPanel),
|
|
2032
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2033
|
+
ApplyBar,
|
|
2034
|
+
{
|
|
2035
|
+
onClear: clearStagedFilters,
|
|
2036
|
+
onApply: applyStagedAndClose,
|
|
2037
|
+
className: classNames?.applyBar
|
|
2038
|
+
}
|
|
2039
|
+
),
|
|
2040
|
+
children: stagedPanel(variant === "toolbar" ? extraFilters : filters)
|
|
2041
|
+
}
|
|
2042
|
+
);
|
|
2043
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1937
2044
|
"main",
|
|
1938
2045
|
{
|
|
1939
2046
|
"data-slot": "search-page",
|
|
1940
2047
|
"data-variant": variant,
|
|
1941
|
-
className: cn(
|
|
1942
|
-
"mx-auto max-w-7xl px-6 py-12",
|
|
1943
|
-
className,
|
|
1944
|
-
classNames?.root
|
|
1945
|
-
),
|
|
2048
|
+
className: cn(className, classNames?.root),
|
|
1946
2049
|
children: [
|
|
1947
|
-
/* @__PURE__ */ (0,
|
|
1948
|
-
/* @__PURE__ */ (0,
|
|
2050
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SearchChromeStyles, {}),
|
|
2051
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: classNames?.header, children: header }),
|
|
2052
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-body", children: [
|
|
1949
2053
|
queryAndSort,
|
|
1950
|
-
variant === "toolbar" ? /* @__PURE__ */ (0,
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
2054
|
+
variant === "toolbar" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-toolbar", className: classNames?.toolbar, children: [
|
|
2055
|
+
toolbarFilters.map((filter) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2056
|
+
ToolbarPopover,
|
|
2057
|
+
{
|
|
2058
|
+
id: filter.id,
|
|
2059
|
+
label: filter.label,
|
|
2060
|
+
open: openToolbar === filter.id,
|
|
2061
|
+
onOpenChange: setOpenToolbar,
|
|
2062
|
+
triggerClassName: classNames?.toolbarTrigger,
|
|
2063
|
+
popoverClassName: classNames?.popover,
|
|
2064
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1960
2065
|
FilterPanel,
|
|
1961
2066
|
{
|
|
1962
2067
|
filters: [filter],
|
|
1963
2068
|
pathFilters: search.pathFilters,
|
|
1964
|
-
onChange:
|
|
2069
|
+
onChange: (id, value) => {
|
|
2070
|
+
search.applyFilter(id, value);
|
|
2071
|
+
if (filter.type !== "range") setOpenToolbar(null);
|
|
2072
|
+
},
|
|
1965
2073
|
rangeDraft,
|
|
1966
2074
|
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
|
|
2075
|
+
onRangeCommit: (id, source) => {
|
|
2076
|
+
commitRange(id, true);
|
|
2077
|
+
if (source === "apply") setOpenToolbar(null);
|
|
1992
2078
|
}
|
|
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)(
|
|
2079
|
+
}
|
|
2080
|
+
)
|
|
2081
|
+
},
|
|
2082
|
+
filter.id
|
|
2083
|
+
)),
|
|
2084
|
+
extraFilters.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FiltersTrigger, { onClick: openStagedFilters }) : null
|
|
2085
|
+
] }) : null,
|
|
2086
|
+
variant === "dialog" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FiltersTrigger, { onClick: openStagedFilters }) : null,
|
|
2087
|
+
variant === "sidebar" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "search-layout", children: [
|
|
2088
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("aside", { "data-slot": "search-sidebar", className: classNames?.sidebar, children: [
|
|
2089
|
+
stagedPanel(filters),
|
|
2090
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2021
2091
|
ApplyBar,
|
|
2022
2092
|
{
|
|
2023
2093
|
onClear: clearStagedFilters,
|
|
2024
|
-
onApply:
|
|
2094
|
+
onApply: search.applyStaged,
|
|
2025
2095
|
className: classNames?.applyBar
|
|
2026
2096
|
}
|
|
2027
2097
|
)
|
|
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
|
|
2098
|
+
] }),
|
|
2099
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
|
|
2100
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FiltersTrigger, { onClick: openStagedFilters }),
|
|
2101
|
+
results
|
|
2102
|
+
] })
|
|
2103
|
+
] }) : results
|
|
2104
|
+
] }),
|
|
2105
|
+
sheet
|
|
2054
2106
|
]
|
|
2055
2107
|
}
|
|
2056
2108
|
);
|
|
@@ -2060,7 +2112,9 @@ function SearchPage({
|
|
|
2060
2112
|
FilterPanel,
|
|
2061
2113
|
ListingCard,
|
|
2062
2114
|
ResultsSkeleton,
|
|
2115
|
+
SearchChromeStyles,
|
|
2063
2116
|
SearchPage,
|
|
2117
|
+
SearchPageFallback,
|
|
2064
2118
|
SearchPagination,
|
|
2065
2119
|
SearchQueryForm,
|
|
2066
2120
|
SearchSortSelect,
|